foreach ($arr as $k => $v){ foreach ($v as $e => $a){ if($a == 1){break;} //if $e has all 1's not just a single 1 (how to code it ?) } } how can I tell the first foreach function to break when $e has all 1's
Obviously this is not the actual code I'm using but its very similar, I need to walk through a two dimensional array and record the keys ($e) when their value ($a) is 1.
The above code finishes right after the first 1 : (
note: my array is not necessarily composed of numeric keys!
There maybe much better ways of tackling this problem.. any ideas?
Thank you so much!
example:
Array ( ["ny"] => Array ( [col0] => "" [col1] => "" [col2] => "" [col3] => "" [col4] => "" [col5] => "" ) ["chicago"] => Array ( [col0] => "1" [col1] => "1" [col2] => "1" [col3] => "1" [col4] => "1" [col5] => "1" ) ) I would like it to stop right after going through chicago.