Home>Article>Backend Development> How to automatically wrap text and images in imagettfbbox and imagettftext in PHP
This article mainly introduces the method of automatic line wrapping of text and pictures in imagettfbbox and imagettftext in PHP. It has a certain reference value. Now I share it with you. Friends in need can refer to it.
mb_internal_encoding("UTF-8"); // 设置编码 // 这几个变量分别是 字体大小, 角度, 字体名称, 字符串, 预设宽度 $content = ""; // 将字符串拆分成一个个单字 保存到数组 letter 中 for ($i=0;$i$width) && ($content !== "")) { $content .= "\n"; } $content .= $l; } // $fontBox = imagettfbbox($fontSize, 0, $font, $text3); imagettftext ( $target, $fontSize, 0, ceil(($width - $fontBox[2]) / 2), 400, $fontColor_black, $font, $content );
The above is this article The entire content, I hope it will be helpful to everyone's study. For more related content, please pay attention to the PHP Chinese website!
Related recommendations:
PHPstorm configures PHPunit to unit test the PHP code introduced by composer
The above is the detailed content of How to automatically wrap text and images in imagettfbbox and imagettftext in PHP. For more information, please follow other related articles on the PHP Chinese website!