Displaying a Random Image from an Array

Category: Software and Systems Engineering
Author: Sean O'Donnell
Thu, Feb. 20th, 2003 @ 2:20:22 (MST)

Here is an example of how to use the array_rand() functions that are built in to PHP 4 and 5.

<?php
$list_item 
= array("geek.jpg","education.jpg");
print 
"<img src=\""$list_item[array_rand($list_item,1)] ."\" border=0>\n";
?> 

The function above should only return one random image.

Copyleft (<) 1998-2019 www.seanodonnell.com