Jump to content

imagepng() and wordwrap()


jackpf

Recommended Posts

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
Share on other sites

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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.