I already posted this on a php forum, but it's been a day without an answer so i thought I might post it here...
I'm trying to make a random quote script, I have a txt file with the quotes, every line a new one, this works... But I want to output it on a image and this is where I need the help.
I want the image to get the size of the line automaticly (so ig the text is Ezra it should be as long as that, and if it's longer it should get wider automaticly), but i also want it too not get too long, like max 300px and if the line is longer, I want it to continue on the next line.
Like this:
Ezra is
cool
This is the code I have so far:
code:
<?
//Header information
header("Content-type: image/gif");
//Get the quote from the file
function randomNummer($van, $tot)
{
srand ((double) microtime() * 1000000); // seed the generator
$return = rand($van,$tot);
return($return);
}
$textLijst = 'randomquote.txt'; // the quotes are in here, on every line a new quote..
$textArray = file($textLijst); // The lines in an array.
$textCount = count($textArray); // How many lines are there??
$randomRegelNummer = randomNummer(0, ($textCount - 1)); // the number of a line.
$textRegel = $textArray[$randomRegelNummer]; // a random line number from the file
//Variabels
$im = @imagecreate(100, 100);
$background_color = imagecolorallocate($im, 100, 100, 100);
$text_color = imagecolorallocate($im, 000, 000, 200);
//Image Code
imagecolortransparent($im, $background_color);
imagestring($im, 5, 7, 3, $textRegel, $text_color);
imagegif($im);
imagedestroy($im);
?>