PHP preg_replace error: Unknown modifier ']' [duplicate]
Apologies for yet another preg_replace question!
I'm getting the error:
Warning: preg_replace() [function.preg-replace]: Unknown modifier ']' in C:\xampp\htdocs\reg.php on line开发者_C百科 6
When running the following preg_replace:
$newContent = preg_replace('<img [^>]*.gif[^>]*?>','MATCHED',$newContent);
I've run the regex through a couple of online regex builders and it seems sound. Any ideas what I'm missing here? Am I using ]
incorrectly?
You need a delimiter around your expression:
$newContent = preg_replace('|<img [^>]*.gif[^>]*?>|','MATCHED',$newContent);
精彩评论