mac address in php code example
Example: can i get mac id of laptop with php
function getMacLinux() {
exec('netstat -ie', $result);
if(is_array($result)) {
$iface = array();
foreach($result as $key => $line) {
if($key > 0) {
$tmp = str_replace(" ", "", substr($line, 0, 10));
if($tmp <> "") {
$macpos = strpos($line, "HWaddr");
if($macpos !== false) {
$iface[] = array('iface' => $tmp, 'mac' => strtolower(substr($line, $macpos+7, 17)));
}
}
}
}
return $iface[0]['mac'];
} else {
return "notfound";
}
}