i need to show 2 different random images.
i tried this code but the second image, show the same image of the first.
i have to replicate this but with 15 random images.
http://www.kometschuh.de/Example-Random-CSS3-Image-Flip-Effect.html
for each <li>
i need to show 2 different random images
<ul class="flip">
<?php
$all_images = glob("wp-content/themes/connexia/img-test/{*.jpg, *.JPG, *.JPEG, *.png, *.PNG}", GLOB_BRACE);
shuffle($all_images);
foreach ($all_images as $index => $image ) {
if ($index == 15) break; // Only print 15 images
$image_name = basename($image);
$image_name2 = basename($image++);
echo "<li>
<img src='/wp-content/themes/connexia/img-test/{$image_name}' />
<img src='/wp-content/themes/connexia/img-test/{$image_name2}' />
</li>";
}
?>
</ul>
Try this:
You can send a 2nd argument to array_rand() to get more than 1.
Also have a look at these links:
http://askwebexpert.com/tutorials/how-to-display-random-images-from-a-directory-using-php/
php generate random image from a directory
PHP pull random image from folder