3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $arr = array( "item1" => array( "conditions" => array( "foo" => true, ), ), "item2" => array( "conditions" => array( "foo" => true, ), ), "item3" => array( "conditions" => array( "foo" => true, ), ), "item4" => array( "conditions" => array( "foo" => false, ), ), "item5" => array( "conditions" => array( "foo" => false, ), ), "item6" => array( "conditions" => array( "foo" => false, ), ), "item7" => array(), "item8" => array(), "item9" => array(), ); $settings = array( "foo" => true, ); foreach($arr as $item_name => $item){ foreach($item["conditions"] as $key => $value){ if($settings[$key] == $value){ echo $item_name, "\n"; } else { break; } } }
based on Vgr6i
Output for 5.3.19 - 7.2.0
item1 item2 item3 Notice: Undefined index: conditions in /in/B0Yjg on line 45 Warning: Invalid argument supplied for foreach() in /in/B0Yjg on line 45 Notice: Undefined index: conditions in /in/B0Yjg on line 45 Warning: Invalid argument supplied for foreach() in /in/B0Yjg on line 45 Notice: Undefined index: conditions in /in/B0Yjg on line 45 Warning: Invalid argument supplied for foreach() in /in/B0Yjg on line 45