3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php function getMeat($foods) { if (!isset($foods['meats'])) { throw new Exception('There is no meat in this pie'); } $meatCount = count($foods['meats']); if($meatCount < 1) { throw new Exception('Where did all the meat go!?'); } var_dump($foods); $i = 0; $j = 1; while($i < $meatCount) { if ($foods['meats'][$i] < $foods['meats'][$j]) { $tempMeat = $foods['meats'][$i]; $foods['meats'][$i] = $foods['meats'][$j]; $foods['meats'][$j] = $tempMeat; } $i++; $j++; } var_dump($foods); } $foods = array( 'meats' => array('cow', 'zucci', 'burgers', 'steak', 'sausages', 'kebabs'), 'cake' => array('victorian', 'chocolate', 'fruit', 'fudge'), ); getMeat($foods);
Output for 5.3.0 - 5.6.28, 7.0.0 - 7.1.0
array(2) { ["meats"]=> array(6) { [0]=> string(3) "cow" [1]=> string(5) "zucci" [2]=> string(7) "burgers" [3]=> string(5) "steak" [4]=> string(8) "sausages" [5]=> string(6) "kebabs" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } } Notice: Undefined offset: 6 in /in/7FMa7 on line 23 array(2) { ["meats"]=> array(6) { [0]=> string(5) "zucci" [1]=> string(3) "cow" [2]=> string(5) "steak" [3]=> string(8) "sausages" [4]=> string(6) "kebabs" [5]=> string(7) "burgers" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } }
Output for hhvm-3.10.0 - 3.12.0
array(2) { ["meats"]=> array(6) { [0]=> string(3) "cow" [1]=> string(5) "zucci" [2]=> string(7) "burgers" [3]=> string(5) "steak" [4]=> string(8) "sausages" [5]=> string(6) "kebabs" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } } Notice: Undefined index: 6 in /in/7FMa7 on line 23 array(2) { ["meats"]=> array(6) { [0]=> string(5) "zucci" [1]=> string(3) "cow" [2]=> string(5) "steak" [3]=> string(8) "sausages" [4]=> string(6) "kebabs" [5]=> string(7) "burgers" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } }
Output for 5.0.0 - 5.2.17
array(2) { ["meats"]=> array(6) { [0]=> string(3) "cow" [1]=> string(5) "zucci" [2]=> string(7) "burgers" [3]=> string(5) "steak" [4]=> string(8) "sausages" [5]=> string(6) "kebabs" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } } Notice: Undefined offset: 6 in /in/7FMa7 on line 23 array(2) { ["meats"]=> array(6) { [0]=> string(5) "zucci" [1]=> string(3) "cow" [2]=> string(5) "steak" [3]=> string(8) "sausages" [4]=> string(6) "kebabs" [5]=> string(7) "burgers" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } }
Output for 4.4.2 - 4.4.9
Parse error: syntax error, unexpected T_NEW in /in/7FMa7 on line 7
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
Parse error: parse error, unexpected T_NEW in /in/7FMa7 on line 7
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/7FMa7 on line 7
Process exited with code 255.