NYCPHP Meetup

NYPHP.org

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

Rolan rolan at datawhorehouse.com
Mon Aug 18 13:03:19 EDT 2003


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
>




More information about the talk mailing list