E.g. with this library or the php-idns functions from pecl
http://www.phpclasses.org/browse/package/1509.html