function imageRandom($dir, $types) {
$images = array();
$new = array();
if ( !empty($types) ) {
$types = explode(",", $types);
foreach ( $types as $t ) {
$glob = $dir . '*.' . $t;
$new = glob( $glob );
if ( !empty( $new ) ) {
$images = (array)$new + (array)$images;
}
}
} else {
$images = glob( $dir . '*.*' );
}
$key = array_rand($images);
$image = $images[$key];
echo $image;
}
?>
|