note 50864 deleted from function.preg-match by colder

From: Date: Mon, 18 Jun 2007 18:21:31 +0000
Subject: note 50864 deleted from function.preg-match by colder
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-127595@lists.php.net to get a copy of this message
Note Submitter: erm(at)the[dash]erm/dot/com ---- This is a modified version of the valid_ipv4 function that will test for a valid ip address with wild cards. ie 192.168.0.* or even 192.168.*.1 function valid_ipv4($ip_addr) { $num="(\*|[0-9]{1,3}|^1?\d\d$|2[0-4]\d|25[0-5])"; if(preg_match("/$num\.$num\.$num\.$num/",$ip_addr,$matches)) { print_r ($matches); return $matches[0]; } else { return false; } }

« previous php.notes (#127595) next »