Skip to content

Instantly share code, notes, and snippets.

@jackey
Created June 15, 2011 07:25
Show Gist options
  • Save jackey/1026639 to your computer and use it in GitHub Desktop.
Save jackey/1026639 to your computer and use it in GitHub Desktop.
optimization array read
$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