It tests the ip for;
1. Need 4 numeric blocks separated by a dot.
2. Each numeric block must noot exceed 255.
3. Shouldn't contain space. So remember to trim before calling this function.
function isINetAddress($ipaddr){
if( preg_match( "/^((?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9]).){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9]?[0-9])$/m",$ipaddr) > 0)
return true;
}
This can't me more simpler. ;)
Enjoy!