jackpf Posted May 21, 2009 Share Posted May 21, 2009 Good...morning all. So yeah, I'm making a random quotes thing, probably like so many of you have done so yourselves. Anyway, I'm using wordwrap(), to wordwrap the quotes (suprisingly). But instead of inserting a new line, it inserts some weird symbol. I couldn't find anyting on google. Just wondering how you guys managed it. Yeah, this is basically my code thus far: $sql = mysql_query("SELECT * FROM `$tb_Quote` WHERE `Status`='1' ORDER BY RAND();") or trigger_error(mysql_error(), E_USER_ERROR); $fetch = mysql_fetch_array($sql); $author = $fetch['Author']; $quote = wordwrap($fetch['Quote'], 50); $img = imagecreate(450, 75); imagecolorallocate($img, 0, 0, 0); $text_colour = imagecolorallocate($img, 255, 255, 255); $line_colour = imagecolorallocate($img, 128, 255, 0); imagestring($img, 2, 2, 5, 'Quote from '.$author, $text_colour); imageline($img, 0, 20, imageSx($img), 20, $line_colour); imagestring($img, 2, 2, 30, $quote, $text_colour); header('Content-type: image/png'); imagepng($img); imagedestroy($img); Cheers, Jack. Oh, here's an example btw. Just refresh the page a couple of times to get a long quote, and you'll see what I mean - http://jackpf.000space.com/quote.php Link to comment https://forums.phpfreaks.com/topic/159007-imagepng-and-wordwrap/ Share on other sites More sharing options...
michaellunsford Posted May 21, 2009 Share Posted May 21, 2009 I'm not seeing any weird character. I did something like this once. I measured to the last space before the length limit and broke the lines into an array. Then cycled through the array, "printing" one line at a time. Unfortunately, I think the actual code is on a backup DVD someplace, and not close at hand. Link to comment https://forums.phpfreaks.com/topic/159007-imagepng-and-wordwrap/#findComment-838630 Share on other sites More sharing options...
jackpf Posted May 21, 2009 Author Share Posted May 21, 2009 Oh yeah, I changed it to use substr() to just append "..." if the text is too long now. But yeah, before there was a yen sign (¥) where the \n should be. I'll change it back. Link to comment https://forums.phpfreaks.com/topic/159007-imagepng-and-wordwrap/#findComment-838855 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.