Regex
What stands out most is your regex patterns are incorrect...
This:
$openQuoteTagCounter = preg_match_all('[quote]', $argText, $openQuoteTagCounter);
$closeQuoteTagCounter = preg_match_all('#\[\/quote\]\s*#', $argText, $closeQuoteTagCounter);
Should be:
$openQuoteTagCounter = preg_match_all('#\[quote\]#i', $argText, $openQuoteTagCounter);
$closeQuoteTagCounter = preg_match_all('#\[/quote\]#i', $argText, $closeQuoteTagCounter);
Which could be further improved:
$openQuoteTagCounter = preg_match_all('#\[quote\]#i', $argText);
$closeQuoteTagCounter = preg_match_all('#\[/quote\]#i', $argText);
The i
is used to make it case insensitive in case you have tags like [QUOTE]
.
You don't need to escape forward slashes (/
) because you're using #
as a delimiter.
You don't need the third argument in the preg_match_all
because you aren't doing anything with it and you're overwriting it anyway...
IF(..)
I also suggest that you use the following code structure
if(X > Y){
//Do stuff...
}
else if(Y > X){
//Do other stuff...
}
else{
//Do different stuff...
}
as opposed to if(...){...} if(...){...} if(...){...} if(...){...}