Skip to content

Instantly share code, notes, and snippets.

@tbaschak
Created December 9, 2013 02:41
Show Gist options
  • Save tbaschak/7866668 to your computer and use it in GitHub Desktop.
Save tbaschak/7866668 to your computer and use it in GitHub Desktop.
calculate network address given IP & Netmask
<?php
// simple example
$bcast = ip2long("192.168.178.41");
$smask = ip2long("255.255.255.0");
$nmask = $bcast & $smask;
echo long2ip($nmask); // Will give 192.168.178.0
echo "\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment