I am working in Drupal 7 on a custom Module using Php.
Under the "Cloud Providers:" section, I am trying to limit the number of entries that print out to only 4. The IF statment with a BREAK is my attempt to solve this issue so far.
I have been trying to figure this out for a few hours and its driving me nuts. Any help would be appreciated. I have put the code at the bottom of this.
Thank you in advance for all your help.
<?php
/**
* @file
*/
?>
<div class="item-body">
<div class="overview">
<div class="label">Cloud Providers:</div>
<div class="data">
<?php
$i = 0;
foreach($company['service_providers'] as $provider): ?>
<div>
<?php
if($i = 3) break;
print $provider;
$i++;
?>
</div>
<?php endforeach; ?>
</div>
</div>
<div class="details">
<?php print theme('cloud_computing_item_details', array('company' => $company)); ?>
</div>
</div>
<div style="clear: both; height: 5px;"> </div>
</div>
</div>
$providers = array_slice($company['service_providers'], 0, 4);
foreach($providers as $provider):
EDIT
or simply
foreach(array_slice($company['service_providers'], 0, 4) as $provider):