note 28016 added to function.substr-count

From: Date: Mon, 30 Dec 2002 01:08:53 +0000
Subject: note 28016 added to function.substr-count
Groups: php.notes 
Request: Send a blank email to php-notes+get-41443@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 -- http://www.php.net/manual/en/function.substr-count.php http://master.php.net/manage/user-notes.php?action=edit+28016 http://master.php.net/manage/user-notes.php?action=delete+28016 http://master.php.net/manage/user-notes.php?action=reject+28016

« previous php.notes (#41443) next »