Created
August 29, 2012 20:20
-
-
Save zanematthew/3518338 to your computer and use it in GitHub Desktop.
Ways to prevent "deep nesting"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
foreach( $items as $item ){ | |
if ( ! $item['name'] ) | |
continue; | |
print $item['name']; | |
// more code | |
// and stuff going on here | |
// and here | |
} | |
// Is the same as... | |
foreach( $items as $item ){ | |
if ( $item['name'] ){ | |
print $item['name']; | |
// more code | |
// and stuff going on here | |
// and here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment