Random Image Generator In PHP

Any problem with PHP can be disscused here
Post Reply
znad
Posts: 250
Joined: Sat Oct 01, 2005 3:12 pm

Random Image Generator In PHP

Post by znad »

Random Image Generator In PHP

Here is a small and basic example of generating random images through PHP!

[PHP]//This line prevents a regular pattern of numbers to be generated.
Srand(microtime() * 1000000);
//This line creates a random integer between 1 and 3
$num = rand(1,3);

//Next we will use a switch statement to display the random image.
Switch($num)
{
case 1: $link=”1”; $img=”images/img1.jpg”; break;
case 2: $link=”2”; $img=”images/img2.jpg”; break;
case 3: $link=”3”; $img=”images/img3.jpg”; break;
}

//Now we will echo the dynamic content.
echo””$link”><img”; [/PHP]


vn29
Posts: 34
Joined: Sun Mar 26, 2006 5:53 pm

Post by vn29 »

is it resize image??
Lixas
Posts: 750
Joined: Wed Feb 16, 2005 4:21 pm

Post by Lixas »

no, exact this script takes one of 3 images and post it to site. Using this script you can use it for random banners or something like that
Image
vn29
Posts: 34
Joined: Sun Mar 26, 2006 5:53 pm

Post by vn29 »

oh i knew what is this for . thank you
kaos_frack
Posts: 504
Joined: Sat May 07, 2005 8:03 am
Contact:

Post by kaos_frack »

you can make it with javascript also

and by the way why do you need this?
do you want to use it for checking for humans?
i mean ask them to enter the code that is in the image?

if yes, then i should say that this not a very good idea
you better generate images with php and fill it with random text
and random numbers
Mizo

Post by Mizo »

its nice to put this script i use it but with more pix
Whatevakid
Posts: 28
Joined: Fri Apr 14, 2006 11:21 am

Post by Whatevakid »

Lol
I find PHP So easy and hard at the same time :oops:
Hello ;]
uz
Posts: 140
Joined: Sat Dec 24, 2005 5:32 pm

Post by uz »

can i add this code to my template in joomla? will it work
Post Reply