3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $input = "turn on 0,0 through 999,999"; $lights = [[]]; for($i = 0; $i<1000; $i++){ for($j = 0; $j<1000; $j++){ $lights[$i][$j] = 0; } } explode("\n",$input); function action($s){ $on = preg_match("/turn on/",$s); $off = preg_match("/turn off/",$s); $toggle = preg_match("/toggle/",$s); if($on > 0){ return 1; } else if($off>0){ return 2; } else if($toggle>0){ return 3; } } echo action($input); ?>
based on SDOZB
Output for 7.0.0 - 7.2.0
1
Output for 5.4.10 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/af7oV on line 8
Process exited with code 255.
Output for 5.3.20 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/af7oV on line 4
Process exited with code 255.