3v4l.org

run code in 300+ PHP versions simultaneously
<?php function BinSearch($needle, $haystack){ $midpoint = count($haystack) / 2; $lower_half = array_slice($haystack, 0, $midpoint); $upper_half = array_slice($haystack, -$midpoint, count($haystack)); if($needle < $midpoint){ BinSearch($needle, $lower_half); } else if($needle > $midpoint){ BinSearch($needle, $upper_half); } if(count($haystack == 1)){ return true;} else if(count($haystack) == 0) { return false;} } $x = range(0,999); BinSearch(82,$x);
based on SaF3u
Output for 7.4.4 - 7.4.14, 8.0.0 - 8.0.3
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/OcTeP on line 13
Process exited with code 255.
Output for 7.1.25 - 7.1.28, 7.2.0 - 7.2.33, 7.3.0 - 7.3.26, 7.4.0
Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to allocate 262144 bytes) in /in/OcTeP on line 7
Process exited with code 255.