note 82397 modified in function.ip2long by danbrown

From: Date: Fri, 05 Dec 2008 13:29:19 +0000
Subject: note 82397 modified in function.ip2long by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-147683@lists.php.net to get a copy of this message
here is netMatch function which is the fastest I could wrote, I hope developers will include native function soon... <?php function netMatch ($CIDR,$IP) { list ($net, $mask) = explode ('/', $CIDR); return ( ip2long ($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($net); } ?> --was-- here is netMatch function which is the fastest I could wrote, I hope developers will include native function soon... function netMatch ($CIDR,$IP) { list ($net, $mask) = explode ('/', $CIDR); return ( ip2long ($IP) & ~((1 << (32 - $mask)) - 1) ) == ip2long ($net); } http://php.net/manual/en/function.ip2long.php

« previous php.notes (#147683) next »