This can be done easily. First way I will show grabs a list of all IP/MAC pairs in case you need that. It then parses the list for the currently connected client's MAC. The second way, just quickly grabs the IP for the currently connected client.
First way:
Run this at the command line to check it gives you a list of IPs=MAC addresses:
arp -en | grep ether | sed -e "s/ \+ether \+/=/g" | grep -ioE "[0-9]{1,3}+(\.[0-9]{1,3}){3}=[0-9a-f]{2}(\:[0-9a-f]{2}){5}"`
Once you know it works, you can incorporate it into your code. First you get the client ip address.
$client_ip=$_SERVER['REMOTE_ADDR'];
Then get a list of MAC addresses:
$arp_output=`arp -en | grep ether | sed -e "s/ \+ether \+/=/g" | grep -ioE "[0-9]{1,3}+(\.[0-9]{1,3}){3}=[0-9a-f]{2}(\:[0-9a-f]{2}){5}"`;
Then parse them to find the right one:
$mac_addresses=explode("\n", $arp_output);
foreach($mac_addresses as $mac_address)
{
$values=explode('=', trim($mac_address));
if ($values[0]==$client_ip)
{
$client_mac_address=$values[1];
}
}
Second way
Put $client_ip
into the command line to get the MAC address directly:
$client_ip=escapeshellarg($_SERVER['REMOTE_ADDR']);
$client_mac_address=`arp -en | grep {$client_ip} | grep -ioE "[0-9a-f]{2}(\:[0-9a-f]{2}){5}" | head -c-1`