Posted By

SeanJA on 08/08/08


Tagged

random images


Versions (?)

Who likes this?

3 people have marked this snippet as a favorite

goo
Jenhale
vali29


Random images


 / Published in: PHP
 

URL: http://seanja.com/blog

Random image (1 in 6, could be more by changing that number) with the name: image_N.png

  1. <img src="image_<?=(rand()%6)?>.png">

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: benphelps on August 10, 2008

in a would work just as well and you save 1 byte!

Posted By: benphelps on August 10, 2008

Well, my comment messed up. Lets try this one more time.

In a <?=?> type open and close, you dont need to end the line with a semicolon.

<?=(rand()%6)?> works just a well and you save 1 byte!

Posted By: SeanJA on August 11, 2008

I usually make it a habit of adding the semi colon so that I can further expand on the script if I want without having to remember to add it later... This was actually put up because of another one that I saw which was way longer than this...

Posted By: SeanJA on August 11, 2008

(it used a text file for the list of images... shudder)

You need to login to post a comment.