-1
我希望Text是「Text Align Right」。PHP:imagettftext text align right(RTL)
$url = "#";
$input = @file_get_contents($url) or die('Fehler!');
if(preg_match_all('~<span class="a">\s*(.*?)\s*</span>~si', $input, $item_name));
$image = imagecreatefrompng("bg.png");
imagesavealpha($image, true);
imagealphablending($image, true);
$finalImage = imagecreatetruecolor(800,200);
$font = '../arial.ttf';
$color = imagecolorallocate($finalImage, 0, 0, 0);
$color_time = imagecolorallocate($finalImage, 100, 100, 100);
imagettftext($image, 10, 0, 23, 15, $color, $font, $item_name[1][0]);
imagettftext($image, 10, 0, 22, 33, $color, $font, $item_name[1][1]);
imagettftext($image, 10, 0, 22, 51, $color, $font, $item_name[1][2]);
imagettftext($image, 10, 0, 22, 69, $color, $font, $item_name[1][3]);
imagettftext($image, 10, 0, 22, 87, $color, $font, $item_name[1][4]);
imagettftext($image, 10, 0, 22, 105, $color, $font, $item_name[1][5]);
imagettftext($image, 10, 0, 22, 123, $color, $font, $item_name[1][6]);
imagettftext($image, 10, 0, 22, 141, $color, $font, $item_name[1][7]);
imagettftext($image, 10, 0, 22, 159, $color, $font, $item_name[1][8]);
imagettftext($image, 10, 0, 22, 177, $color, $font, $item_name[1][9]);
imagettftext($image, 10, 0, 22, 195, $color, $font, $item_name[1][10]);
header('Content-type: image/png');
imagepng($image);
你知道嗎? 因爲我沒有明白。 我已經谷歌很多。 你們需要知道,我不是真的得到了PHP,這就是爲什麼我需要幫助。 如果您有問題,請詢問!
gd只將文字放在您告訴它的位置。它沒有「左對齊」或「右對齊」。你需要自己實現:http://php.net/manual/en/function.imagettfbbox.php –
@MarcB好的,以及如何? – ZarneXxX
閱讀鏈接。學會使用你得到的工具。退出「查找函數'do_exactly_what_I_need()'」的思維模式,並進入use()的思維模式。 simple_tools();提供();去完成(); complicated_things();' –