How can i replace unused section in content. For example:
$content = "
Test content
[section]
Section Content
[section]
End.
";
$content = preg_replace('/\[section\](.*)\[section\]/', '', $content);
Thanks
The s modifier allows a dot metacharacter in the pattern to match all characters, including newlines.
The i modifier is used for case-insensitive matching allowing both upper and lower case letters. By adding the quantifier ? it makes for a non greedy match and matches the least amount possible.
$content = preg_replace('/\[section\].*?\[section\]/si', '', $content);
See Demo
smodifier to match newlines with.. Also don't forget to make your expression ungreedy/\[section\](.*?)\[section\]/s