<?php $host=gethostbyaddr($_SERVER['REMOTE_ADDR']); $patt='/\.(?P<host>[a-z]+)/'; preg_match($patt,$host,$matches); echo $matches["host"]."\n"; ?>