Welcome Guest, Not a member yet? Register   Sign In
doing if statement around the first part of array
#1

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
Reply


Messages In This Thread
doing if statement around the first part of array - by doomie22 - 03-27-2018, 07:04 AM



Theme © iAndrew 2016 - Forum software by © MyBB