well im more of a perl coder then php, but i'd run a while loop, while its going through the message, for each [-quote] set $number-of-quotes-in-message (or whatever) +1 - then before continuing, if $numberofquotes == $X, replace [-quote] with whatever. now im not sure how you'd do that in php, sorry, but that would be how i'd attempt it.
edited because im an idiot

([-quote] w/ no -)