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.254', ['167.98.48.0']));
based on 0URqF
Output for 7.2.0 - 7.4.1
bool(false)