In this simple case, the preg_replace
function will probably work. For more stability, try using DOMDocument
:
$string = 'http://google.com';
$dom = new DOMDocument;
$dom->loadXML($string);
$link = $dom->firstChild;
$link->nodeValue = str_replace('http://', '', $link->nodeValue);
$string = $dom->saveXML($link);