hey guys! i found a sweet function at http://www.php.net/manual/en/function.imagestring.php that wraps text when using the imagestring() function, but the problem is that when u press enter(for a new line) it displays a unicode character, i cant paste it here case phpbuilder changes it to a different char (character map calls it "U+0433") how can i make the ImageStringAlignAndWrap() function not display this character, i cant type it in my code, so i figure i have to use some kinda unicode to utf converting function or something. i have no idea where to begin....here's the ImageStringAlignAndWrap() function:
if(!function_exists('ImageStringAlignAndWrap')){ // prevent function redeclare
function ImageStringAlignAndWrap($image, $font, $text, $color, $shadow, $drop, $maxwidth, $alignment, $valign, $padding="5") {
$fontwidth = ImageFontWidth($font);
$fontheight = ImageFontHeight($font);
$margin = floor($padding + $drop)/2; // So that shadow is not off image on right align & bottom valign
if ($maxwidth != NULL) {
$maxcharsperline = floor( ($maxwidth - ($margin 2)) / $fontwidth);
$text = wordwrap($text, $maxcharsperline, "\n", 1);
}
$lines = explode("\n", $text);
switch($valign){
case "center":
$y = (imageSY($image) - ($fontheight sizeof($lines)))/2;
break;
case "bottom":
$y = imageSY($image) - (($fontheight sizeof($lines)) + $margin);
break;
default:
$y = $margin;
break;
}
switch($alignment){
case "right":
while (list($numl, $line) = each($lines)) {
ImageString($image, $font, (imagesx($image) - $fontwidthstrlen($line))-$margin+$drop, ($y+$drop), $line, $shadow);
ImageString($image, $font, (imagesx($image) - $fontwidthstrlen($line))-$margin, $y, $line, $color);
$y += $fontheight;
}
break;
case "center":
while (list($numl, $line) = each($lines)) {
ImageString($image, $font, floor((imagesx($image) - $fontwidthstrlen($line))/2)+$drop, ($y+$drop), $line, $shadow);
ImageString($image, $font, floor((imagesx($image) - $fontwidth*strlen($line))/2), $y, $line, $color);
$y += $fontheight;
}
break;
default:
while (list($numl, $line) = each($lines)) {
ImageString($image, $font, $margin+$drop+100, ($y+$drop), $line, $shadow);
ImageString($image, $font, $margin+100, $y, $line, $color);
$y += $fontheight;
}
break;
}
} // end function
} // end function_exists
Thanks for any help!I love php!yay!