note 103353 modified in function.hexdec by danbrown

From: Date: Fri, 08 Apr 2011 22:26:17 +0000
Subject: note 103353 modified in function.hexdec by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-178648@lists.php.net to get a copy of this message
Here is a function to transform a MAC Address to decimal. <?php function get_mac_decimal($mac) { $invalid = array(":", "-", ";", ".", " "); $clear_mac = str_replace($invalid, "", $mac); $mac_decimal = ""; for ($i = 0; $i < strlen($clear_mac); $i = $i + 2) { $mac_decimal .= hexdec(substr($clear_mac, $i, 2)); if ($i < strlen($clear_mac) - 2) { $mac_decimal .= "."; } } return $mac_decimal; } ?> --was-- Here is a function to transform a MAC Address to decimal. function get_mac_decimal($mac) { $invalid = array(":", "-", ";", ".", " "); $clear_mac = str_replace($invalid, "", $mac); $mac_decimal = ""; for ($i = 0; $i < strlen($clear_mac); $i = $i + 2) { $mac_decimal .= hexdec(substr($clear_mac, $i, 2)); if ($i < strlen($clear_mac) - 2) { $mac_decimal .= "."; } } return $mac_decimal; } http://php.net/manual/en/function.hexdec.php

« previous php.notes (#178648) next »