3v4l.org

run code in 200+ PHP versions simultaneously
<?php function ipCidrCheck($IP, $CIDRArray) { foreach ($CIDRArray as $CIDR) { if (preg_match('#/#', $CIDR)) { list ($net, $mask) = split("/", $CIDR); } else { $net = $CIDR; $mask = 32; } $ip_net = ip2long($net); $ip_mask = ~((1 << (32 - $mask)) - 1); $ip_ip = ip2long($IP); $ip_ip_net = $ip_ip & $ip_mask; if ($ip_ip_net == $ip_net) { return true; } } return false; } var_dump(ipCidrCheck('167.98.48.0', ['167.98.48.0/24']));
based on ImZBD
Output for 7.0.0 - 7.4.1
Fatal error: Uncaught Error: Call to undefined function split() in /in/FYQLa:7 Stack trace: #0 /in/FYQLa(29): ipCidrCheck('167.98.48.0', Array) #1 {main} thrown in /in/FYQLa on line 7
Process exited with code 255.
Output for 5.4.0 - 5.6.40
Deprecated: Function split() is deprecated in /in/FYQLa on line 7 bool(true)
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.3.29
Parse error: syntax error, unexpected '[' in /in/FYQLa on line 29
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '[' in /in/FYQLa on line 29
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/FYQLa on line 29
Process exited with code 255.