3v4l.org

run code in 300+ PHP versions simultaneously
<?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/"); $off = preg_match("/turn off/"); $toggle = preg_match("/toggle/"); if($on > 0){ return 1; } else if($off>0){ return 2; } else if($toggle>0){ return 3; } } echo action($input); ?>
Output for 8.0.0 - 8.0.30, 8.1.0 - 8.1.1, 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Fatal error: Uncaught ArgumentCountError: preg_match() expects at least 2 arguments, 1 given in /in/SDOZB:15 Stack trace: #0 /in/SDOZB(15): preg_match('/turn on/') #1 /in/SDOZB(29): action('turn on 0,0 thr...') #2 {main} thrown in /in/SDOZB on line 15
Process exited with code 255.
Output for 8.1.2 - 8.1.27
Fatal error: Out of memory (allocated 31457280) (tried to allocate 36864 bytes) in /in/SDOZB on line 8 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for 7.0.0 - 7.0.20, 7.1.0 - 7.1.7, 7.1.20, 7.2.0 - 7.2.33, 7.3.16 - 7.3.33, 7.4.0 - 7.4.33
Warning: preg_match() expects at least 2 parameters, 1 given in /in/SDOZB on line 15 Warning: preg_match() expects at least 2 parameters, 1 given in /in/SDOZB on line 16 Warning: preg_match() expects at least 2 parameters, 1 given in /in/SDOZB on line 17
Output for 7.1.10

Process exited with code 137.
Output for 5.5.24 - 5.5.35, 5.6.8 - 5.6.28
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 72 bytes) in /in/SDOZB on line 8
Process exited with code 255.

preferences:
170.91 ms | 402 KiB | 184 Q