Here is the loop.
foreach($results->results as $result){
echo '<div id="twitter_status">';
echo '<img src="'.$result->profile_image_url.'" class="twitter_image">';
$text_n = $result->text;
echo "<div id='text_twit'>".$text_n."</div>";
echo '<div id="twitter_small">';
echo "<span id='link_user'".'<a href="http://www.twitter.com/'.$result->from_user.'">'.$result->from_user.'</a></span>';
$date = $result->created_at;
$dateFormat = new DateIntervalFormat();
$time = strtotime($result->created_at);
echo "<div class='time'>";
print sprintf('Submitted %s ago', $dateFormat->getInterval($time));
echo '</div>';
echo "</div>";
echo "</div>";
With the
breakcommand.You are missing a bracket though.
More info about the
breakcommand at: http://php.net/manual/en/control-structures.break.phpUpdate: As Kyle pointed out, if you want to break the loop it’s better to use
forrather thanforeach. Basically you have more control of the flow and you gain readability. Note that you can only do this if the elements in the array are contiguous and indexable (as Colonel Sponsz pointed out)The code would be:
It’s cleaner, it’s more bug-proof (the control variables are all inside the
forstatement), and just reading it you know how many times it will be executed.break/continueshould be avoided if possible.