I'm using this script to display one random image from a folder with subfolders:
<?php
$imagesDir = glob('folders/pics/*', GLOB_ONLYDIR);
$randomfolder = $imagesDir[array_rand($imagesDir)];
$images = glob($randomfolder . '/*.{jpg,jpeg,png,gif}', GLOB_BRACE);
$randomImage = $images[array_rand($images)];
echo '<img src="'.$randomImage.'" class="image">';
?>
Everything works fine! But for now I want to show 5 images at the same time (for a caroussel-slider). I used the following code
$randomImage = $images[array_rand($images, 5)];
but it shows me this warning:
Warning: Illegal offset type […]
What am I doing wrong?