Related

3 Replies to “IP Matching With CIDR Notation In PHP”

Thanks for the excellent function, Bill! I also tried some functions from http://www.php.net; some of them I could tell wouldn’t always work, and some seemed like the would until I tested them. I guess when all else fails you just need to go back to the basics of converting bitmasks and IP addresses. I appreciate the commented code! You will find this code in Tera-WURFL 2.1.1 (TeraWurflWebservice.php) once I release it!

You’re darn right about not being able to find an answer, no matter how hard you Google – I’ve spent nearly a week trying out various scripts, with no luck until I found this one. Thanks a million.

The crucial info was to express the array with quotes around each CIDR, and once I did this with other solutions found where you mentioned, many of them worked. Unfortunately they just said ‘use an array’ without showing exactly how.