NYCPHP Meetup

NYPHP.org

[nycphp-talk] I need a function that will compare IP addresses

Phil Powell soazine at erols.com
Mon Aug 18 13:32:46 EDT 2003


I'm from Southeast DC, Rolan, so everything I do is ghetto: ;)

function is_identicalThreeNodeIP($ip1, $ip2) {
 return (substr($ip1, 0, strrpos($ip1, '.')) === substr($ip2, 0,
strrpos($ip2, '.'))) ? '1' : '0';
}

Phil
----- Original Message ----- 
From: "Rolan" <rolan at datawhorehouse.com>
To: "NYPHP Talk" <talk at lists.nyphp.org>
Sent: Monday, August 18, 2003 1:03 PM
Subject: Re: [nycphp-talk] I need a function that will compare IP addresses


> or the ghetto way:
>
> function compareip($ipa,$ipb) {
>     if (stristr(strrev($ipa),".")==stristr(strrev($ipb),".")) {return
true;}
>     else {return false;}
> }
>
> ~Rolan
>
> Hans Zaunere wrote:
>
> >
> >
> > Phil Powell wrote:
> >
> >>  have written a function that is supposed to compare the first three
> >> nodes of an IP address, but it is riddled with errors that I have
> >> given up trying to figure out.
> >>
> >> Is there an existing function out there that can do this? I want to
> >> compare "127.0.0.1" with "127.0.0.100" and come with as a "match", or
> >> "127.0.0.1" with "127.0.0.1", but no "match if "127.0.0.1" and
> >> "127.255.0.0".
> >
> >
> > IPs are really just long ints.
> >
> > This should take care of things:
> >
> > http://us4.php.net/ip2long
> >
> >
> > H
> >
> > _______________________________________________
> > talk mailing list
> > talk at lists.nyphp.org
> > http://lists.nyphp.org/mailman/listinfo/talk
> >
>
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list