3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php function convert($url) { return preg_replace('#:\/\/([^.]*\.)?'.preg_quote('mydomain.tld').'#', '://example.dev', $url); } var_dump(convert('http://mydomain.tld/ferfe')); var_dump(convert('https://mydomain.tld/ferfe')); var_dump(convert('http://foo.mydomain.tld/ferfe')); var_dump(convert('https://foo.mydomain.tld/ferfe'));
based on L3XnV
Output for 4.3.0 - 7.2.6
string(24) "http://example.dev/ferfe" string(25) "https://example.dev/ferfe" string(24) "http://example.dev/ferfe" string(25) "https://example.dev/ferfe"