PHP Magic Book – Free PHP Scripts, Tutorials and Downloads, PHP AtoZ Reloaded, free php tutorials, free php downloads, php scripts, PHP tips

Random Single Image Display On Page Reload Using PHP

Very small yet wow kind of script that takes a folder and displays random script image at every time page reloads.

PHP Code

<?php
$files = glob("images/*.*");
mt_srand( (double) microtime() * 1000000 );
$num = mt_rand(0, count($files)-1);
echo '<img src="'.$files[$num].'" alt="" />';
?>

In this example ‘images’ is the folder containing all the images. Every time page reloads, it will display different image.

Random Single Image On Page Reload PHP Script Download

  • Share/Bookmark
Tags: , , ,
Posted in: Randomizing, Rotating Content
Post's RSS » RSS 2.0
Post's Comments RSS » RSS 2.0

Related Posts




Post a Comment

  Subscribe Via RSS
  Subscribe Via Email