note 106377 modified in function.dechex by danbrown
| From: | danbrown@php.net | Date: | Fri, 04 Nov 2011 13:59:17 +0000 |
| Subject: | note 106377 modified in function.dechex by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-184297@lists.php.net to get a copy of this message | ||
for mac address
<?php
function dec2mac($mac) {
$mac=preg_split("([.])", $mac, 6);
$hexmac="";
foreach ($mac as $part)
{
$part=dechex($part);
strlen($part)<2 ? $hexmac.="0$part" : $hexmac.=$part;
}
return $hexmac;
}
echo dec2mac("0.29.96.71.60.137"); // 001d60473c89
?>
--was--
for mac address
<?php
function dec2mac($mac) {
$mac=preg_split("([.])", $mac, 6);
$hexmac="";
foreach ($mac as $part) $hexmac.=dechex($part);
return substr($hexmac,0,4).".".substr($hexmac,4,4).".".substr($hexmac,8,4);
}
?>
http://php.net/manual/en/function.dechex.php