This worked nicely for me
rand_img.php
PHP Code:
function RandImg($dir) {
$images = glob($dir . '*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
return $randomImage;
}
$ads1_image = RandImg('../dir/path/toimages/');
use
echo "$ads1_image";