So let's walk through exactly what this code is doing.
First, we're getting the IP address of the user that is currently viewing the page. $_SERVER is a predefined variable available on all* boxes running php. The documentation shows this here:
The IP address from which the user is viewing the current page.
Then you're setting a variable $macaddr to false. You'll be filling this with data, but it might still be false in the future, so you should be performing some checks before attempting to access it. More on that later...
PHP has an execution operator. This involves wrapping code in backticks to execute code on the server and is pretty much the same as shell_exec() - except when using it you don't have the overhead of a function call.
You're executing arp 127.0.0.1 as you would in the command line and returning the results as an array before placing it in the $arp variable.
You're then splitting the string with explode() on any spaces, and finally attempting to read the third element of the array.
Firstly, you should be checking that the third element of the array exists. If it doesn't, the arp command went wrong and didn't return what you expected, and you should be throwing useful Exceptions to explain what went wrong to future users of your code.
Secondly, you should be checking at the end that $macaddr contains the sort of information you want, possibly by a regex or similar validation functionality.
Finally, why aren't you getting back what you want from sending arp to the command line? Well, first, try running arp yourIpAddressHere in your command line and make sure it's returning some data. I get "no entry" when I do it, so sort out your command first, in command-line, before getting PHP to do it so you can use it in your code.
*Unless you're been messing around with things you shouldn't have been.
Why I think it won't work
I'm trying your arp command. Here are my results:
- Trying
arp on localhost with my ip address, both internal and external
I get "no entry" back. Because on my localhost the addresses are all hostnames and not ip addresses, and mine isn't in the list.
- Trying
arp on a remote server
I only get back the ip address of the server from the arp command. So trying to access the visiting user's mac address just won't work, because the execution is happening on the server. Not on the user's computer.
In conclusion, you're trying to do something hacky - accessing the user's mac address for nefarious purposes. I'm not about to help you any further with this answer.