3v4l.org

run code in 300+ PHP versions simultaneously
<?php $input = "turn off 499,499 through 500,500"; $lights = [[]]; for($i = 0; $i<1000; $i++){ for($j = 0; $j<1000; $j++){ $lights[$i][$j] = 0; } } //$inputs = 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; } } //for($i = 0; $i < count($inputs); $i++){ $matches = null; preg_match_all("/\d{1,3},\d{1,3}/",$inputs[$i], $matches); $from = $matches[0][0]; $to = $matches[0][1]; $x1 = explode(",",$from)[0]; $y1 = explode(",",$from)[0]; $x2 = explode(",",$to)[0]; $y2 = explode(",",$to)[1]; for($j = $y1; $j<=$y2; $j++){ for($k = $x1; $k<=$x2; $k++){ if(action($inputs[$i])===1){ $lights[$j][$k] = 1; } else if(action($inputs[$i])===2){ $lights[$j][$k] = 0; } else if(action($inputs[$i])===3){ if($lights[$j][$k] === 0){ $lights[$j][$k] = 1; } else{ $lights[$j][$k] = 0; } } } } //} $count = 0; for($i = 0; $i<1000; $i++){ for($j = 0; $j<1000; $j++){ if($lights[$i][$j] === 1){ $count++; } } } echo $count; ?>
Output for git.master
Warning: Undefined variable $inputs in /in/TW0gU on line 31 Warning: Trying to access array offset on value of type null in /in/TW0gU on line 31 Deprecated: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 31 Warning: Undefined array key 0 in /in/TW0gU on line 32 Warning: Undefined array key 1 in /in/TW0gU on line 33 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 34 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 35 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 36 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 37 Warning: Undefined array key 1 in /in/TW0gU on line 37 Warning: Undefined variable $inputs in /in/TW0gU on line 40 Warning: Trying to access array offset on value of type null in /in/TW0gU on line 40 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 Warning: Undefined variable $inputs in /in/TW0gU on line 43 Warning: Trying to access array offset on value of type null in /in/TW0gU on line 43 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 Warning: Undefined variable $inputs in /in/TW0gU on line 46 Warning: Trying to access array offset on value of type null in /in/TW0gU on line 46 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 0
Output for git.master_jit
Fatal error: Out of memory (allocated 18874368 bytes) (tried to allocate 20480 bytes) in /in/TW0gU on line 8 mmap() failed: [12] Cannot allocate memory mmap() failed: [12] Cannot allocate memory
Process exited with code 255.
Output for rfc.property-hooks
Warning: Undefined variable $inputs in /in/TW0gU on line 31 Warning: Trying to access array offset on null in /in/TW0gU on line 31 Deprecated: preg_match_all(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 31 Warning: Undefined array key 0 in /in/TW0gU on line 32 Warning: Undefined array key 1 in /in/TW0gU on line 33 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 34 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 35 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 36 Deprecated: explode(): Passing null to parameter #2 ($string) of type string is deprecated in /in/TW0gU on line 37 Warning: Undefined array key 1 in /in/TW0gU on line 37 Warning: Undefined variable $inputs in /in/TW0gU on line 40 Warning: Trying to access array offset on null in /in/TW0gU on line 40 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 Warning: Undefined variable $inputs in /in/TW0gU on line 43 Warning: Trying to access array offset on null in /in/TW0gU on line 43 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 Warning: Undefined variable $inputs in /in/TW0gU on line 46 Warning: Trying to access array offset on null in /in/TW0gU on line 46 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 15 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 16 Deprecated: preg_match(): Passing null to parameter #2 ($subject) of type string is deprecated in /in/TW0gU on line 17 0

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:
64.17 ms | 408 KiB | 8 Q