note 22397 added to function.is-numeric

From: Date: Sun, 16 Jun 2002 23:33:20 +0000
Subject: note 22397 added to function.is-numeric
Groups: php.notes 
Request: Send a blank email to php-notes+get-31925@lists.php.net to get a copy of this message
A faster IP check. <?php function is_ip($ip) { $ip = explode(".", $ip); foreach($ip as $block) { if(!is_numeric($block)) { return false; } } return true; } ?> Just taking out the extra variable, and it will also return when the first invalid block is found, instead of going through all blocks. -- http://www.php.net/manual/en/function.is-numeric.php http://master.php.net/manage/user-notes.php?action=edit+22397 http://master.php.net/manage/user-notes.php?action=delete+22397 http://master.php.net/manage/user-notes.php?action=reject+22397

« previous php.notes (#31925) next »