From:             [EMAIL PROTECTED]
Operating system: Linux
PHP version:      4.2.3
PHP Bug Type:     Feature/Change Request
Bug description:  Suggestion: New function, is_ip

function is_ip($str) // Returns True if the given string is a IP address
{
if ((substr_count($str, ".") != 3) or (empty($str))) { return false; }

$ip_array = explode(".", $str);

for ($i = 0; $i < count($ip_array); $i++)
{
   if ((strlen($ip_array[$i]) != 3) or (!is_numeric($ip_array[$i])))
   {
     return false;
   }
}

return true;
}

I think that this function could be useful for many PHP coders :)
-- 
Edit bug report at http://bugs.php.net/?id=21277&edit=1
-- 
Try a CVS snapshot:         http://bugs.php.net/fix.php?id=21277&r=trysnapshot
Fixed in CVS:               http://bugs.php.net/fix.php?id=21277&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=21277&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=21277&r=needtrace
Try newer version:          http://bugs.php.net/fix.php?id=21277&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=21277&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=21277&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=21277&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=21277&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=21277&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=21277&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=21277&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=21277&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=21277&r=gnused

Reply via email to