3v4l.org

run code in 300+ PHP versions simultaneously
<?php $urls = [ 'https://danielabruña.com/', 'https://fagualópez.com/', 'https://laconspiracióndelcastellano.com/', ]; foreach ($urls as $url) { $raw_domain = parse_url($url, PHP_URL_HOST); $encoded_domain = idn_to_ascii($raw_domain); $new_url = substr_replace($url, $encoded_domain, stripos($url, $raw_domain), strlen($raw_domain)); var_dump($url, $new_url); }
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
string(26) "https://danielabruña.com/" string(32) "https://xn--danielabrua-beb.com/" string(24) "https://fagualópez.com/" string(30) "https://xn--fagualpez-b7a.com/" string(41) "https://laconspiracióndelcastellano.com/" string(47) "https://xn--laconspiracindelcastellano-ctc.com/"

preferences:
105.6 ms | 407 KiB | 5 Q