Created
June 15, 2011 07:25
-
-
Save jackey/1026639 to your computer and use it in GitHub Desktop.
optimization array read
This file contains 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
$array = array( | |
'field_item_1' => array( | |
'field_sub_item_11' => array('field' => TRUE, 'title' => 'sub field item 1'), | |
'field_sub_item_12' => array('field' => FALSE, 'title' => 'sub field item 2'), | |
), | |
'field_item_2' => array( | |
'field_sub_item_21' => array('field' => TRUE, 'title' => 'sub field item 21'), | |
), | |
); | |
foreach ($array as $item => $field) { | |
// I do not want to have this foreach. | |
foreach ($field as $k => $v) { | |
if ($v['field']) { | |
// Do something. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment