Skip to content

Instantly share code, notes, and snippets.

@kcchien
Created April 7, 2020 05:28
Show Gist options
  • Save kcchien/953375567154df7c9d6f5f516dcf7d4f to your computer and use it in GitHub Desktop.
Save kcchien/953375567154df7c9d6f5f516dcf7d4f to your computer and use it in GitHub Desktop.
<?php
$ipAddress=$_SERVER['REMOTE_ADDR'];
$matches=array();
echo 'IP:' . $ipAddress . '<br>';
# Execute arp
$arp=`arp -a $ipAddress`;
# Parsing MAC address from arp result
preg_match('/([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}/', $arp, $matches);
# MAC address will be stored at index 0 of the array
echo 'MAC Address: ' . $matches[0];
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment