I have nested quotes enabled in my private message system, but now I want to show the user a part of the message when they hover the title of the message.
To get the relevant text out of the message I want to delete the quote parts.
The quote structure is as follows:
[quote]
[quote]
dasdasa adsadsa ds a
[/quote]
ddasd asd ads adsasd
[/quote]
How can I remove everything between de quote tags?
I have tried it with the following code, but the last part of the nested quotes won’t remove:
while(preg_match('#\[quote=(.*?)\](.*?)\[\/quote\]#si', $message)) {
$message = preg_replace('#\[quote=(.*?)\](.*?)\[\/quote\]#si', '', $message, 1);
}
while(preg_match('#\[quote\](.*?)\[\/quote\]#si', $message)) {
$message = preg_replace('#\[quote\](.*?)\[\/quote\]#si', '', $message, 1);
}
Any suggestions how to delete these quotes out of the message? Thx!
a) better not use regex…
b) use recursion.
I haven’t tested the pcre, but it should do.