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://haha.com/ferfe')); var_dump(convert('https://haha.com/ferfe')); var_dump(convert('http://foo.haha.com/ferfe')); var_dump(convert('https://foo.haha.com/ferfe'));
based on 9ACf0
Output for 4.3.0 - 7.2.6
string(21) "http://haha.com/ferfe" string(22) "https://haha.com/ferfe" string(25) "http://foo.haha.com/ferfe" string(26) "https://foo.haha.com/ferfe"