PHP Code for this file

<?php

// ignore this block of code
print "<h2>PHP Code for this file</h2>";
highlight_file(__FILE__);
print 
"<br />";

?>
    
<?php

// the images.. one per line, add a ',' to the end of each line
// excluding the last one
$images = array(
    
'/images/1.jpg',
    
'/images/2.jpg',
    
'/images/3.jpg',
    
'/images/4.jpg',
    
'/images/5.jpg',
    
'/images/6.jpg'
);

function 
getRandomImage()
{
    global 
$images;
    
    
$key = (mt_rand() % count($images));
    
$file $images[$key];
    
    unset(
$images[$key]);
    
$images array_values($images);

    return 
$file;
}

print 
"<h2>Images randomly loaded.</h2>";

$arr_len count($images);
for(
$x=0$x $arr_len$x++)
{
    print 
"<img src=\"http://scriptplayground.com/article_files/Building-a-Smarter-Random-Image-Loader/"getRandomImage() . "\" />" "<br />";
}

?>

Images randomly loaded.