note 93016 modified in function.preg-match by danbrown

From: Date: Wed, 19 Aug 2009 19:49:07 +0000
Subject: note 93016 modified in function.preg-match by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-159650@lists.php.net to get a copy of this message
The following function works well for validating ip addresses <?php function valid_ip($ip) { return preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" . "(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $ip); } ?> --was-- The following function works well for validating ip addresses function valid_ip($ip) { return preg_match("/^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])" . "(\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$/", $ip); } http://php.net/manual/en/function.preg-match.php

« previous php.notes (#159650) next »