我可以在php中将trim()与imagettftext()一起使用吗?
我需要在由php函数创建的png文件中换行:imagettftext(); 这对我来说很好,但我需要像这样断线:我可以在php中将trim()与imagettftext()一起使用吗?,php,fonts,gd,Php,Fonts,Gd,我需要在由php函数创建的png文件中换行:imagettftext(); 这对我来说很好,但我需要像这样断线: $arrText=explode("\n",wordwrap($text,20,"\n")); $y=5; //vertical position of text foreach($arrText as $arr) { imagestring($image,10,15,$y,trim($arr),$white); $y=$
$arrText=explode("\n",wordwrap($text,20,"\n"));
$y=5; //vertical position of text
foreach($arrText as $arr)
{
imagestring($image,10,15,$y,trim($arr),$white);
$y=$y+15;
}
但我无法将自定义字体与imagestring()一起使用
最佳解决方案是什么?我使用:
$arrText=explode("\n",wordwrap($text,50,"\n"));
$y=120; //vertical position of text
foreach($arrText as $arr)
{
imagettftext($image, 20, 0, 40, $y, $mycolor, $font, trim($arr));
// imagettftext ( resource $image , float $size , float $angle , int $x , int $y , int $color , string $fontfile , string $text )
$y=$y-40;
}
使用fullimagettftext返回一个坐标数组。在这方面,您希望能够
trim()
做些什么?trim()需要一个字符串