Your string contains a whole mess of /
which would need to be escaped as \/
when using /
as the regex delimiter. Instead of /
as the regex delimiters, use something which won't occur in your string like ~
for example. You must choose a delimiting character which is guaranteed not to appear in $Src
, however. You might be safer even with |
than with ~
.
$Src = 'images/pages/clients/logos/clnt_aljareera_img.jpg';
// Delimit the regular expression with ~
$pttn= '~&Src:'.$Src.'~';
$string=preg_replace($pttn,'',$string,1);
What has happened is your regex delimited by /
encounters a p
immediately after images/
because it thinks it has reached the closing delimiter. The next word pages
is mistakenly treated as a string of regex modifiers.
PHP sees the regular expression:
/&src:images/pages