FRIHOST • FORUMS • SEARCH • FAQ • TOS • BLOGS • COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


fdas





yahoo-tosses
i know what u mean brother Wink
yahoo-tosses
i completely understand you
virtualpointer
[quote="PatTheGreat42"]Well, that garnered some feedback...

Anyways, here's the code for the actual PHP page. You'll notice that the code requires a suitable PNG background. I also used the .htaccess solution, so I've got a .htaccess file running too.

I also tried to add the occasional helpful comment here and there.

[code]
<?php
//Grab text from RSS feed.
$rss = file("http://www.4q.cc/chuck/rss.php");
$clean = trim(strip_tags($rss[13]));
//Backup facts, in case original fact is too long.
if(strlen($clean) > 200 or $clean == "")
{
$foo[] = "There once was a man from Nantucket. Chuck Norris paralyzed him from the waist down.";
$foo[] = "Chuck Norris's communication with The Afterlife is made possible by talking to the black guy on Walker Texas Ranger.";
$foo[] = "If you see Chuck Norris crying he will grant you a wish, if your wish is dying.";
$foo[] = "If you make Chuck Norris stroke his beard in confusion, you're finished, because Norris doesn't understand confusion, only pain.";
$foo[] = "The only reason World War II occured was because Chuck Norris was taking a nap.";
$foo[] = "What's behind Chuck Norris' beard? Nothing. Just another fist.";
$clean = $foo[rand(0,5)];
}
//Explode the fact and put each word into it's own part of an array. Then, I can string the words back together, all the while making sure each line isn't too long. The lines go into a new array, $fact.
foreach(explode(" ",$clean) as $blargh)
{
$linelength = $linelength + 1 + strlen($blargh);
if($linelength < 33)
{$fact[$arraynum] = $fact[$arraynum]." ".$blargh;}
else
{
$linelength = strlen($blargh) + 1;
$arraynum++;
$fact[$arraynum] = $fact[$arraynum]." ".$blargh;
}
}
//Put it in the picture. I have no idea how this works.
Header ("Content-type: image/png");
$img_handle = imageCreateFromPNG("chucknorris.png");
$color = ImageColorAllocate($img_handle,255,255,0); //RGB values for font color.
//Font size, x-offset, and y-offset. Font values 1-5. 1 smallest.
$yoffset = 5;
//Put each item in array $fact into the picture.
foreach($fact as $chuck)
{
ImageString($img_handle,3,140,$yoffset,$chuck,$color);
//Increase y offset for new line.
$yoffset+=15;
}
ImagePng($img_handle);
ImageDestroy($img_handle);
//Original Code: http://www.icemelon.com/tutorials/9/Dynamic_Images.htm.
//This is some of the prettiest code I've ever done, I'd like to say.
?>
[/code]

And as a side note, I screwed up the first time. The pic should really be (I hope) here: [url]http://www.patthegreat.com/Steven/chuck/chucknorrissig.php[/url].

Here's the final product:
[img]http://www.patthegreat.com/Steven/chuck/chucknorrissig.png[/img][/quote]

Hi, Dude,

I tried this segment of code, but it gave me the following error info:

The image “http://www.xxx.com/test/test.php” cannot be displayed, because it contains errors.

Could you give me a suggestion?
virtualpointer
Forgot tellling you that the server I run the code support PHP, version 4.4.0, and has GD support.

Sorry for bothing you, I am really interested iin the dynamic display.
Related topics
Campaign for the regulation of pet food industry
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.