Just the function I needed, cheers sde.
1 slight possible improvement is removing the strstr, and instead checking explicitly (===) for 0 on strpos.
PHP Code:
function checkIP($ip_to_match, $ip_array) {
// make sure this is an array before we use foreach
if (is_array($ip_array)) {
// loop through ip array
foreach ($ip_array as $ip) {
// first test if there is a match, then test if the match starts at the beginning
if (strpos($ip_to_match, $ip)===0) {
return true;
}
}
}
return false;
}