3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $arr = array( array("PROPERTIES" => array(1122), "QUANTITY" => "11"), array("PROPERTIES" => array(1123), "QUANTITY" => "12") ); function getQuantityById($id) { foreach ($arr as $item) { if ($item["PROPERTIES"][0] == $id) return $item["QUEANTITY"]; } return null; } echo getQuantityById(1122);
Output for 5.1.0 - 7.1.0
Notice: Undefined variable: arr in /in/JvIGv on line 9 Warning: Invalid argument supplied for foreach() in /in/JvIGv on line 9
Output for 4.3.0 - 4.3.10, 4.4.0 - 5.0.5
Warning: Invalid argument supplied for foreach() in /in/JvIGv on line 9
Output for 4.3.11