I'm currently creating a PNG image from a random sql statment. Its just outputting text, but I was to limit the number of chars per line. I have this working, but its repeating the text to the next line.

Below is the code on how I'm doing this.

imagestring($image, 1, 365, 5, "ID: $id", $font_black);
// Break quote up into pieces 60 characters long
$str = wordwrap($quote, 60, '|');
$lines = explode('|', $str);

The output would be like,

The quick brown fox jumped
fox jumped over the cat.

If anyone has any ideas on how to fix this that would be awesome!

I'm still trying to figure out what you actually require. Please provide the following information

1. imagestring() puts the string "ID:$id" in your example into the image. What is the value of $id ? What does this have to do with the $str.

2. What is the value of $quote?

3. What are you trying to do? Create different images with the string o only use the first part of the text or actually wrap the string in the image?

Please answer the above questions so that we can help you out.

I actually figured it out below is the code.

$srt = wordwrap($quote, 60, "\n");
$lines = explode("\n", $srt);
$y = 15;
$i = 0;
foreach($lines as $line=>$string){
		imagestring($image, 2, 5, $y, $string, $font_black);
		$string = substr($string, 1);
		$y += 12;
	if(++$i == 5) break;

@BaSk: Please mark this post as solved since you now have your answer.