NYCPHP Meetup

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

Daniel Kushner nyphp at websapp.com
Mon Aug 18 13:17:01 EDT 2003


> or the ghetto way:
>
> function compareip($ipa,$ipb) {
>     if (stristr(strrev($ipa),".")==stristr(strrev($ipb),"."))
> {return true;}
>     else {return false;}
> }

In general, it is good practice to return the Boolean evaluation in such
cases:

function compareip($ipa,$ipb) {
    return stristr(strrev($ipa),".")==stristr(strrev($ipb),".");
}


Best,
Daniel Kushner





More information about the talk mailing list