Quantcast
Channel: CodeIgniter Forums - All Forums
Viewing all articles
Browse latest Browse all 14115

doing if statement around the first part of array

$
0
0
Hi, 

I am trying to figure out how to do an if statement that the first one in the array has a different layout that the rest.

Here is my example:

Code:
<?php foreach ($x as $y) : ?>
   <?php if (This is the part I cannot figure.) : ?>
     <div class="col-sm-6 col-md-12">
        ...
     </div>
  <?php else : ?>
     <div class="col-sm-6 col-md-4">
        ...
     </div>
  <?php endif; ?>
<?php endforeach; ?>

So I want the first item in the array to have the col-sm-6 and col-md-12, but then all the others to have col-md-4 instead.

Just not sure how I can tell the if to look if its the first item [0]

Thanks,
Doomie

Viewing all articles
Browse latest Browse all 14115

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>