I'm trying to create a random quote image, but it has to be constrained to 500x75px. The problem I'm running into is making the string wrap to a new line so it doesn't get cut off. I'm probably just being retarded, but I can't think of how to do it. I'm pretty sure I need to use strlen(), but what I need to do is beyond me.
Here's what I have so far; the problem is, long quotes get cut off after reaching 500px width.
<?php
// quotes array
$q[0]="quote1";
$q[1]="quote2";
...
// rand
$rand=mt_rand(0,3);
// create png from random quote
header("Content-type: image/png");
$im = @imagecreate(500, 75)
or die("something broke");
$background_color = imagecolorallocate($im, 255, 255, 255);
$txt_color = imagecolorallocate($im, 0, 0, 0);
imagestring($im, 5, 5, 5, "$q[$rand]", $txt_color);
imagepng($im);
imagedestroy($im);
?>