note 110024 added to function.ip2long

From: Date: Wed, 12 Sep 2012 17:38:24 +0000
Subject: note 110024 added to function.ip2long
Groups: php.notes 
Request: Send a blank email to php-notes+get-190673@lists.php.net to get a copy of this message
Re: hanguofeng at gmail dot com http://www.php.net/manual/en/function.ip2long.php#102898 <? function check_ip($needle, $haystack_array) { foreach($haystack_array as $a) { $a = str_replace('.', '\.', $a); $a = str_replace('*','[0-9]+', $a); if(preg_match("/^{$a}$/", $needle) return true; } return false; } $filter = check_ip('126.1.0.2', array( '127.0.0.1', '172.0.0.*', '173.0.*.*', '126.1.0.0/255.255.0.0', '125.0.0.1-125.0.0.9', )); ?> "Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function. " -- John Carmack ---- Server IP: 69.147.83.197 Probable Submitter: 132.170.82.46 ---- Manual Page -- http://www.php.net/manual/en/function.ip2long.php Edit -- https://master.php.net/note/edit/110024 Del: integrated -- https://master.php.net/note/delete/110024/integrated Del: useless -- https://master.php.net/note/delete/110024/useless Del: bad code -- https://master.php.net/note/delete/110024/bad+code Del: spam -- https://master.php.net/note/delete/110024/spam Del: non-english -- https://master.php.net/note/delete/110024/non-english Del: in docs -- https://master.php.net/note/delete/110024/in+docs Del: other reasons-- https://master.php.net/note/delete/110024 Reject -- https://master.php.net/note/reject/110024 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#190673) next »