Regular Expresion Work on IP address
| From: | Dev | Date: | Wed, 04 Dec 2002 19:04:44 +0000 |
| Subject: | Regular Expresion Work on IP address | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-127017@lists.php.net to get a copy of this message | ||
Hello all,
Let me first say thank you to Jason Wong and Adam Voigt for their help on my problem with Multidimensional Arrays!!!
Now I am continuing on with the same script and I need to check for valid IP address form.
Currently I have:
$ip="255.255.255.0";
if (preg_match ("/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/", $ip)) {
print "Good Ip";} else {
print "Bad Ip";} This does work kinda. It checks to see if the 4 sets of numbers are well there and numbers. The problem I am having is that it does not check to see if the IP is in a proper range ie less than 255.255.255.255 So you could enter 256.256.256.999 and it will say that it is a good IP. Any clue how I would change it to check for that????