Can anyone find the solution for this error,
$str= trim(strip_tags($str));
$str = preg_replace("'<style[^>]*>.*</style>'siU",'',$str);
$patterns = array();
$patterns[0] = ' ';
$patterns[1] = ' ';
$patterns[2] = ' ';
$replacements = array();
$replacements[0] = '';
$replacements[1] = '';
$replacements[2] = ' ';
$str = preg_replace($patterns, $replacements, $str开发者_运维技巧);
It showing this error.
Message: preg_replace() [function.preg-replace]: No ending delimiter '&' found
-Arun
The first character in your pattern is interpreted as a delimiter and right now PHP thinks you want to use & as a delimiter. In your first regex, the delimiter was '
, BTW. I guess what you really want is not ' '
, but '/ /'
(e.g. for pattern 2), now /
is the delimiter (it is not part of the regex itself). BTW, your first regex seems not correct either, it should probably be
'<style[^>]*>[^<]*</style>'
Otherwise the regex could match the first tag and the very last tag of the whole document.
You have the anwser in the error code, regex needs delimiters to work.
And you should use str_replace for
.
精彩评论