Wallogit.com
2017 © Pedro Peláez
Network helpers
This is a work-in-progress collection of functions useful for storing network data in a database. The available methods are:, (*1)
mac2long - Converts a MAC address in a long int. Default separators are ':' and '-', (*2)
long2mac - Converts a long int into a MAC address. Default separator is ':', (*3)
Add "vjandrea/network" to your project's composer.json., (*4)
"require": {
"vjandrea/network": "dev-master"
},
"minimum-stability" : "dev"
Then update via composer, (*5)
composer update
Remember to add use VJAndrea\Network; when you want to use the function provided by this helper., (*6)
Example: i want to convert a MAC address to an integer for easier database storage:, (*7)
$mac = '01-23-45-67-89-0A'; $long = Network::mac2long($mac); // $long value now is 1250999896330
Example: i want to take a MAC address that i saved as integer in the db and format it properly for the user:, (*8)
$long = 1250999896330; $mac = Network::long2mac($long); // $mac value now is '01:23:45:67:89:0A'