I am trying out preg_replace to replacing relative URL paths with absolute URL paths, here's what I have so far:
<?php
$search = 'href="@/@';
$replace = 'http://google.com/';
$link = '<a id=1a class=q href="/imghp?hl=en&tab=wi&ie=UTF-8">Google Image Search Linky</a>';
$absolute = preg_replace($search, $replace, $link);
echo $absolute;
?>
I want to get
<a id=1a class=q href="http://google.com/imghp?hl=en&tab=wi&ie=UTF-8">Google Image Search Linky</a>
But, I get the following error:
Warning: preg_replace(): Delimiter must not be alphanumeric or backslash in pregtest.php on line 5
Could someone please help me and explain this to me please? 😕