note 112579 added to function.preg-match
| From: | hessemanj2100 at gmail dot com | Date: | Mon, 01 Jul 2013 17:05:39 +0000 |
| Subject: | note 112579 added to function.preg-match | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-195422@lists.php.net to get a copy of this message | ||
The most accurate IPv4 function. It will not allow leading zeros and supports the full address range
of 0.0.0.0 - 255.255.255.255
<?php
function is_ipv4($string)
{
// The regular expression checks for any number between 0 and 255 beginning with a dot (repeated 3
times)
// followed by another number between 0 and 255 at the end. The equivalent to an IPv4 address.
return (bool) preg_match('/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])'.
'\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]?|[0-9])$/', $string);
}
?>
----
Server IP: 69.147.83.199
Probable Submitter: 68.47.110.71
----
Manual Page -- http://php.net/manual/en/function.preg-match.php
Edit -- https://master.php.net/note/edit/112579
Del: integrated -- https://master.php.net/note/delete/112579/integrated
Del: useless -- https://master.php.net/note/delete/112579/useless
Del: bad code -- https://master.php.net/note/delete/112579/bad+code
Del: spam -- https://master.php.net/note/delete/112579/spam
Del: non-english -- https://master.php.net/note/delete/112579/non-english
Del: in docs -- https://master.php.net/note/delete/112579/in+docs
Del: other reasons-- https://master.php.net/note/delete/112579
Reject -- https://master.php.net/note/reject/112579
Search -- https://master.php.net/manage/user-notes.php