PHPverse 2025

Voting

: min(one, one)?
(Example: nine)

The Note You're Voting On

tjpoe at cableaz dot com
20 years ago
i modified the centering functions and created this which centers each word on it's own line. You can adjust the spacing with the $valign var. currently no implimentation if text is too large for image. strings are tokenized by space, but can obviously be changed.

function ImageStringWrap($image, $font, $text, $color)
{
$fontwidth = ImageFontWidth($font);
$fontheight = ImageFontHeight($font);
$words= str_word_count($text);
if ($words > 1){
$string=array(strtok($text,' '));
for ($i = 1 ; $i <= $words ; $i++){
$string=array_merge($string,array($i=>strtok(' ')));
}
}
else
$string=$text;
$vspace=4;
$y=((imagesy($image)-($fontheight*$words)-($words*$vspace))/2);
foreach($string as $st){
$x=((imagesx($image)-($fontwidth * strlen($st)))/2);
ImageString($image,$font,$x,$y,$st,$color);
$y+=($fontheight+$vspace);
}
}
hope this is helpful

<< Back to user notes page

To Top