我正在尝试编写一个函数,它将检查打开的 bbcode 标记和关闭的 bbcode 标记。
这是我到目前为止所写的:
public function CheckBBCodes($argText)
{
$openQuoteTagCounter = preg_match_all('[quote]', $argText, $openQuoteTagCounter);
$closeQuoteTagCounter = preg_match_all('#\[\/quote\]\s*#', $argText, $closeQuoteTagCounter);
if($openQuoteTagCounter > $closeQuoteTagCounter)
{
echo "There are more open quote tags than close quote tags!";
}
if($closeQuoteTagCounter > $openQuoteTagCounter)
{
echo "There are more close quote tags than open quote tags!";
}
}
它不起作用。我忘记了什么?