Hey guys,

Trying to workout a way to check if an IP address if is in the same network from the network address and the subnet mask. Also reporting back the broadcast address would be useful.

It's been a few years since I've had to do any binary calculatotions, especially in PHP.

Can anyone point me in the correct direction? Not sure if there's some functions for it already built into PHP either. Google search hasn't really helped (Sure there's guides, but nothing for PHP).

The normal subnet masks are easy to calculate, like 255.255.0.0 for class B etc - you can hardcode the logic for them. It's the trickier ones that are harder. Basically breaking down the IP address and subnet mask into binary and running XOR functions on them?