Simple PHP Random Image

Simple way to mix elements of an array made with glob() & shuffle() functions:

<?php
function randomize() {
$pics = glob("*.jpg");
shuffle($pics);
return $pics[0];
}
echo '<img src="/images/' . randomize() . '.jpg" alt="" />';
?>

In this case the elements are JPEG files.

~ by angrybee on December 25, 2007.

Leave a Reply

You must be logged in to post a comment.