lundi 8 août 2022

how to display image randomly inside for loop in php

i have a simple webpage where i am trying to echo multiple images, my code is like below

<?php for($l=1;$l<=45;$l++){?>

<div class="thumb" style="background-image: url(l<?=$l?>.jpg);"></div>

<?php } ?>

so here the images are displayed fine in an order from 1 to 45, but what i want is images to display randomly everytime the page is loaded, can anyone please tell me how to accomplish this, thanks in advance




Aucun commentaire:

Enregistrer un commentaire