3v4l.org

run code in 300+ PHP versions simultaneously
<?php $sInput = 'toggle 0,0 through 999,0'; $aLights = array(); for($x = 0; $x < 1000; $x++) { for($y = 0; $y < 1000; $y++) { $aLights[$x . 'x' . $y] = false; } } $aInput = explode("\r\n", $sInput); foreach($aInput as $sInput) { preg_match('#(?<action>turn (?:on|off)|toggle) (?<from_x>[0-9]{1,3}),(?<from_y>[0-9]{1,3}) through (?<to_x>[0-9]{1,3}),(?<to_y>[0-9]{1,3})#', $sInput, $aMatch); for($x = $aMatch['from_x']; $x <= $aMatch['to_x']; $x++) { for($y = $aMatch['from_y']; $y <= $aMatch['to_y']; $y++) { switch($aMatch['action']) { case 'turn on': $aLights[$x . 'x' . $y] = true; break; case 'turn off': $aLights[$x . 'x' . $y] = false; break; case 'toggle': $aLights[$x . 'x' . $y] = ($aLights[$x . 'x' . $y] ? false : true); break; } } } } echo count(array_filter($aLights));
Output for git.master, rfc.property-hooks
Fatal error: Out of memory (allocated 20971520 bytes) (tried to allocate 20971520 bytes) in /in/cVVXk on line 10 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for git.master_jit
Fatal error: Out of memory (allocated 11534336 bytes) (tried to allocate 10485760 bytes) in /in/cVVXk on line 10 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
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:
42.12 ms | 401 KiB | 8 Q