php gd文本在图像上休息

Bad*_*yes 1 html php gd gdi

我试图打破一个长短语,取决于我的摩天大楼横幅宽度大小,不能超过三个字,我搜索互联网,发现一个脚本,通过设置短语的字符来打破文本,这是它.

<?

header("Content-type: image/png");
$string = $_GET['text']. '  Click Here';
$im     = imagecreatefrompng("../../images/skyscrapper.png");
$orange = imagecolorallocate($im, 0, 0, 0);
$px     = (imagesx($im) - 3.8 * strlen($string)) / 2;
$font = 'verdana.ttf';

// Break it up into pieces 10 characters long
$lines = explode('|', wordwrap($string, 10, '|'));

// Starting Y position
$y = 450;

// Loop through the lines and place them on the image
foreach ($lines as $line)
{
imagestring($im,3, $px, $y, $string, $orange);

    // Increment Y so the next line is below the previous line
    $y += 23;
}

imagepng($im);
imagedestroy($im);



?>
Run Code Online (Sandbox Code Playgroud)

问题是输出复制短语三次而不是打破文本作为此屏幕截图文字保持重复 ,有人可以帮助解释问题是什么,我该怎么办?

Mar*_*c B 5

你没有$string在循环中改变.不应该是:

imagestring($im,3, $px, $y, $line, $orange);
                            ^^^^^
Run Code Online (Sandbox Code Playgroud)

代替?