note 28016 rejected from function.substr-count by jmcastagnetto

From: Date: Mon, 30 Dec 2002 08:16:38 +0000
Subject: note 28016 rejected from function.substr-count by jmcastagnetto
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-41458@lists.php.net to get a copy of this message
This is a good example that claims how useful substr_count can be. This function checks if the given string is a IP address. 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; } If you like this function, please vote it: http://bugs.php.net/bug.php?id=21277

« previous php.notes (#41458) next »