I am running a foreach over an array and am looking to break up my foreach statement into four stages:
<?php foreach ($result->data as $post): ?>
<?php if($photo_count < 2) { ?>
<!-- Renders images. @Options (thumbnail,low_resoulution, high_resolution) -->
<a class="col-md-2" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php $photo_count++; ?>
<?php echo $photo_count; ?>
<?php } elseif($photo_count = 2) { ?>
<p>testing</p>
<?php $photo_count++; ?>
<?php echo $photo_count; ?>
<?php } elseif($photo_count > 2) { ?>
<a class="col-md-2" rel="group1" href="<?= $post->images->standard_resolution->url ?>"><img src="<?= $post->images->thumbnail->url ?>"></a>
<?php $photo_count++; ?>
<?php echo $photo_count; ?>
<?php } else {
break;
} ?>
<?php endforeach ?>
Earlier I declared $photo_count to equal 1. Basically what I want to do is: -When the photo count is less than 2 - do something -When the photo count is equal to 2 - do something -When the photo count is great than 2 - do something.
For some reason it is getting stuck when $photo_count is equal to 3 and looping over that.
Any advice would be appreciated.