3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getMeat($foods) { if (!isset($foods['meat'])) { 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( 'meat' => array('burgers', 'steak', 'sausages', 'kebabs'), 'cake' => array('victorian', 'chocolate', 'fruit', 'fudge'), ); getMeat($foods);
Output for git.master, git.master_jit, rfc.property-hooks
Warning: Undefined array key "meats" in /in/t5Qgg on line 10 Fatal error: Uncaught TypeError: count(): Argument #1 ($value) must be of type Countable|array, null given in /in/t5Qgg:10 Stack trace: #0 /in/t5Qgg(42): getMeat(Array) #1 {main} thrown in /in/t5Qgg on line 10
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
39.08 ms | 401 KiB | 8 Q