Thanks for the reply KeyStorm
, However, i'm still having trouble
I added your code to mine and ended up with this:
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
//$text = $textRegel; //the actual string you want to output
$size = 4; //the size of the font
$angle = 0; //the angle of the font (0 for horizontal)
$maxlen = 290; //the maximum length that should be allowed (for 300px it's ok to set 290 in here)
// Keystorms Improvemend by slicing
$slices = explode(' ',$textRegel);
$split = count($slices);
do{
$split--;
$out1 = NULL;
for($i=0;$i<=$split;$i++)
{
$out1 .= $slices[$i]." ";
}
$break = imagettfbbox($size,$angle,$fontpath,$out1);
} while ($break[2] > $maxlen);
$out2 = NULL;
for($j=$i; $j<count($slices); $j++)
{
$out2 .= $slices[$j].' ';
}
//Image code, edited by Keystorm
$im = imagecreate($break[2]+10,50);
$background_color = imagecolorallocate($im, 100, 100, 100);
$text_color = imagecolorallocate($im, 000, 000, 200);
imagecolortransparent($im, $background_color);
imagettftext($img,$size,$angle, 5, 15, $text_color, $font, $out1."\n\r".$out2);
imagegif($im);
imagedestroy($im);
?>
But the image doesn't get outputted, this is what I get:
http://school.tsdme.nl/randomquote/plaatje2.php
Yes, i'm a php n00b
, and I'm trying to do things that I can't, but i'm still learning...