I'm sure there is a quick and easy answer to this, it's just not coming to me right now. I have built custom html/css/js for a slider that pulls its content from an array like this:
$slides = [
[
'img' => 'image1.jpg',
'text' => 'Slide One text',
'svg' => 'cat1'
],
[
'img' => 'image2.jpg',
'text' => 'Slide Two Text',
'svg' => 'cat2'
],
// First slide
[
'img' => 'image3.jpg',
'text' => 'Slide Three Text',
'svg' => 'cat3'
],
[
'img' => 'image4.jpg',
'text' => 'Slide Four Text',
'svg' => 'cat4'
],
[
'img' => 'image5.jpg',
'text' => 'Slide Five Text',
'svg' => 'cat5'
],
];
I built the slider in a way that the css/js is dependent on the third slide being active. The slide wrapper then resets for mobile and the first slide in the array is the first slide in the rendered html. I do not want to change/update the css structure as it is controlling about 5 media query breakpoints and very specific to a unique design. I am hoping that there is a simple way that I can just reorder the array in the html, so that on Desktop the third slide is the first and on mobile the first slide is the first. Is there an easy way to do this that I'm just not think of? My html looks like this:
<div class="home-slider-wrap">
<?php foreach ($slides as $index=>$slide): ?>
<div class="home-slider-slide slide<?php echo $index; ?> <?php if($index == 2){ echo 'active'; } ?>" data-slide="<?php echo $index; ?>">
<img src="/images/homepage/<?php echo $slide[img]; ?>" alt="<?php echo $slide['text']; ?>">
</div>
<?php endforeach; ?>
</div>
I want to keep the <?php if($index == 2){ echo 'active'; } ?> so that I don't have to update the js or css, but want to reorder the array. Hope that makes sense.