1
我想根据我的摩天大楼横幅宽度尺寸打破一个很长的短语,我无法承受超过三个字,我搜索了互联网,并找到了一个脚本,通过设置字符长对于这句话来说,就是这样。php gd在图像上的文字突破
<?
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);
?>
问题是输出重复这句话的三倍,而不是打破的文字与此屏幕截图 ,有人可以帮助解释什么问题,我应该怎么办?
OPS,新手的错误,谢谢:) – 2012-04-16 21:27:13