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