Reputation: 461
I have this as part of a preg_replace
array
// CENTER ITEMS
$pattern[5] = '/\[center\](.*?)\[\/center\]/i';
$replace[5] = "<div class=\"centerText\">$1</div>";
It works as long as whatever it is finding is like
[center]lol[/center]
But if the text is like
[center]hello
my name is steve
[/center]
It does not work how can I solve this?
Thanks
Upvotes: 0
Views: 85
Reputation: 4060
Add the "s" modifier, which will include newlines in the match text.
s (PCRE_DOTALL) If this modifier is set, a dot metacharacter in the pattern matches all characters, including newlines. Without it, newlines are excluded. This modifier is equivalent to Perl's /s modifier. A negative class such as [^a] always matches a newline character, independent of the setting of this modifier.
http://www.php.net/manual/en/reference.pcre.pattern.modifiers.php
Upvotes: 1