Skip to content

Instantly share code, notes, and snippets.

@dewski
Created September 4, 2009 18:33
Show Gist options
  • Select an option

  • Save dewski/181025 to your computer and use it in GitHub Desktop.

Select an option

Save dewski/181025 to your computer and use it in GitHub Desktop.
<?php
$i = 0;
$vars = array('a', 'b', 'c', 'd', 'e', 'f');
foreach($vars as $var) {
if($i==2) break;
// do what you want
++$i;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment