-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();' –