I have a loop
where I am inserting some html
element and I need to add a class
to it but I need this class
to be from 1 to 4 max, like gallery__item--3
or gallery__item--1
and applied randomly without duplicates and avoid gallery__item--3
and gallery__item--3
.
Currently I do the following but I get duplicates and I am not sure how to check:
$min = 1;
$max = 4;
foreach( $galleria as $image ):
<figure class="gallery__item--<?php echo rand($min,$max); ?>">
endforeach;
Literally looking for:
1,3,4,2
or 4,2,1,3