Website Tutorials
Recipes
Entertainment Reviews
Home Remedies
Game Codes and Cheats
PHP Coding Tutorials | Submited May 22, 2008
What's this?
One - Create an array
// This is an array of images - you can add more by duplicationg $imgs
$imgs[] = "http://sevenbeasts.com/random/photoshopuserbar.png";
$imgs[] = "http://sevenbeasts.com/random/phpUserbar.png";
$imgs[] = "http://sevenbeasts.com/random/Skem9Userbar.png";
Two - Randomize
// This is the part that makes it display at random
srand ((double) microtime() * 1000000);
$randIMG = rand(0,count($imgs)-1);
srand() | microtime() | rand()
Three - Header
//Set the content type as a PNG image
Header ("Content-type: image/png");
Four - Create the image
// This creates an image from the array of images we made earlier
$doIt = imageCreateFromPNG("".$imgs[$randIMG]."");
Five - Make it a PNG
// make the image a PNG
ImagePng ($doIt);
Six - DESTROY
// Self explanitory
ImageDestroy ($doIt);
Done.
<?php
// This is an array of images - you can add more
$imgs[] = "http://sevenbeasts.com/random/photoshopuserbar.png";
$imgs[] = "http://sevenbeasts.com/random/phpUserbar.png";
$imgs[] = "http://sevenbeasts.com/random/Skem9Userbar.png";
// This is the part that makes it display at random
srand ((double) microtime() * 1000000);
$randIMG = rand(0,count($imgs)-1);
//Set the content type as a PNG image
Header ("Content-type: image/png");
// This creates an image from the array of images we made earlier
$doIt = imageCreateFromPNG("".$imgs[$randIMG]."");
// make the image a PNG
ImagePng ($doIt);
// Self explanitory
ImageDestroy ($doIt);
?>