- var_dump: documentation ( source)
- preg_replace: documentation ( source)
<?php
function convert($url) {
return preg_replace(':\/\/([^.]*\.)?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'));