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('zucci', 'burgers', 'steak', 'sausages', 'kebabs'), 'cake' => array('victorian', 'chocolate', 'fruit', 'fudge'), ); getMeat($foods);
Output for 5.5.0 - 7.1.0
array(2) { ["meats"]=> array(5) { [0]=> string(5) "zucci" [1]=> string(7) "burgers" [2]=> string(5) "steak" [3]=> string(8) "sausages" [4]=> 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: 5 in /in/s9kNh on line 23 array(2) { ["meats"]=> array(5) { [0]=> string(5) "zucci" [1]=> string(5) "steak" [2]=> string(8) "sausages" [3]=> string(6) "kebabs" [4]=> 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.4.45
array(2) { ["meats"]=> array(5) { [0]=> string(5) "zucci" [1]=> string(7) "burgers" [2]=> string(5) "steak" [3]=> string(8) "sausages" [4]=> string(6) "kebabs" } ["cake"]=> array(4) { [0]=> string(9) "victorian" [1]=> string(9) "chocolate" [2]=> string(5) "fruit" [3]=> string(5) "fudge" } } array(2) { ["meats"]=> array(5) { [0]=> string(5) "zucci" [1]=> string(5) "steak" [2]=> string(8) "sausages" [3]=> string(6) "kebabs" [4]=> 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
<br /> <b>Parse error</b>: syntax error, unexpected T_NEW in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1
<br /> <b>Parse error</b>: parse error, unexpected T_NEW in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255.
Output for 4.3.2 - 4.3.4
<br /> <b>Parse error</b>: parse error in <b>/in/s9kNh</b> on line <b>7</b><br />
Process exited with code 255.