<?php
//This will get an array of all the .gif images in a folder
$img_array = glob("/path/to/images/*.gif");
//Pick a random image from the array
$img = array_rand($img_array);
//Display the image on the page
echo '<img alt="'.$img_array[$img].'" src="'.$img_array[$img].'" />';
?>
Suggested Difficulty Level: Novice
Current Score: 2.57
Total votes: 163
Total Views: 1100
Other top snippets by Admin:
1. Add (th, st, nd, rd, th) to the end of a number
2. JPG to ASCII Converter
3. Dynamic Page Content From Links
4. AJAX Quickie
5. Simple Image CAPTCHA
1. URL Shortening for (1 of 5)
2. Monthly Content Sorting (2 of 8)
3. Show String Trimmed (1.89 of 9)
4. Human readable file (2.33 of 9)
5. Randomize array values (1.67 of 6)
6. Create a recursive (1.67 of 6)
7. Simple URI location (1.67 of 6)
8. Tell how many, (1.63 of 8)
9. Create thumb from (2.47 of 15)
10. Tell how many, (2.31 of 13)
1. True Colors to (1 of 4)
2. Seconds to Duration (2 of 5)
3. Dynamic CSS Style (1.67 of 6)
4. Check a string (1 of 5)
5. Domain From a (1.33 of 6)
6. Convert String To (2.57 of 7)
7. Session Through Domain (2.93 of 28)
8. Get Image From (2.36 of 55)
9. Get Directories in (3.09 of 47)
10. Hex To RGB (3.27 of 49)
11. Round To The (2.99 of 104)
12. Valid Image Check (2.93 of 127)
13. Referer Tracking (3.52 of 79)
14. Force File Download (3.05 of 127)
15. Trasparent Gif (3.09 of 170)
16. Dynamic Table From (3.14 of 132)
17. Row Colorization (3.07 of 138)
18. Display Time In (3.03 of 152)
19. Text Output Format (3.1 of 220)
20. Temperature Converter (3.11 of 164)
21. Unzip Zip File (3.04 of 160)
22. Smart Upper Casing (2.68 of 168)
23. Mean, Median, Mode, (2.85 of 155)
24. Display File Size (2.98 of 181)
25. Advanced Image CAPTCHA (3.19 of 256)
Home | Forum | Free PHP Web Hosting | Contact | Terms & Conditions
PHPSnips.com - ©2009
01/04/2009