note 22397 deleted from function.is-numeric by didou
| From: | didou@php.net | Date: | Sun, 18 May 2003 10:18:43 +0000 |
| Subject: | note 22397 deleted from function.is-numeric by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-48501@lists.php.net to get a copy of this message | ||
Note Submitter: sacrdias@xmission.com
----
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.