gethostbyaddr($ipaddress)
will return a host name. Note that not all IP addresses have a valid host name associated with it.
So if you put in an IP address nad it returns a valid hostname, you would then want to write a little code that will chop off the host part of the address. You could do something like this:
$hostname = gethostbyaddr($ipaddress);
$names = explode('.', $hostname);
shift($names); // gets rid of the first part
$modified_hostname = implde('.', $names);
This will turn the hostname dialup221.fl.someisp.net into fl.someisp.net. You can then do this:
$modified_hostname = '(---.'.$modified_hostname.')';
to get the above format.
Check out the string and array function to get more info on this.