I have this string :
$body = '<a href="/title/tt2034800/?ref_=inth_ov_tt"> The Great Wall</a>';
And i want to remove :
?ref_=inth_ov_tt
From $body .
I test this code and didn't work :
$body = preg_replace('#ref_=(.*?)"#is', '', $body);
Change your regex pattern to the following:
$body = '<a href="/title/tt2034800/?ref_=inth_ov_tt"> The Great Wall</a>';
$body = preg_replace('#\?ref_=([^"]+)(?=")#i', '', $body);
print_r($body);
The output(as source code):
<a href="/title/tt2034800/"> The Great Wall</a>
?to remove exactly what you want to remove.