Postingan Yang Kamu Cari

Sabtu, 27 Maret 2010


by John Email
This can be useful for banner ads.
function getRandomImage( ) {

$path = ""; // Replace with your path

$img_list = array();

$dir = opendir( $path );

// Get all the files in the directory

while( $img = readdir($dir) )
{
if( $img != "." && $img != "..")
{
$img_list[] = $img;
}
}

closedir($dir);

// Randomly select a file from the list
$rand_img = rand(0, count($img_list)-1 );
$rand_img = $img_list[$rand_img];

return $rand_img;
}

Tidak ada komentar: