Code:
function checkbbcode($text)
{
$bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $text);
$bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
$bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
$bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
$bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
$testa = array("b1","i1","u1","big1","small1");
$checka = substr_count($bbcheck,$testa);
$testb = array("b2","i2","u2","big2","small2");
$checkb = substr_count($bbcheck,$testb);
if($checka!=$checkb){
$text = "BB Code Error";
}
$bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $text);
$bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
$bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
$bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
$bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
$testa = array("b1","i1","u1","big1","small1");
$checka = substr_count($bbcheck,$testa);
$testb = array("b2","i2","u2","big2","small2");
$checkb = substr_count($bbcheck,$testb);
if($checka!=$checkb){
$text = "BB Code Error";
}
$bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $text);
$bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
$bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
$bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
$bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
$testa = array("b1","i1","u1","big1","small1");
$checka = substr_count($bbcheck,$testa);
$testb = array("b2","i2","u2","big2","small2");
$checkb = substr_count($bbcheck,$testb);
if($checka!=$checkb){
$text = "BB Code Error";
}
$bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $text);
$bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
$bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
$bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
$bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $bbcheck);
$testa = array("b1","i1","u1","big1","small1");
$checka = substr_count($bbcheck,$testa);
$testb = array("b2","i2","u2","big2","small2");
$checkb = substr_count($bbcheck,$testb);
if($checka!=$checkb){
$text = "BB Code Error";
}
$bbcheck=preg_replace("/\[small\](.*?)\[\/small\]/i","small1small2", $text);
$bbcheck=preg_replace("/\[big\](.*?)\[\/big\]/i","big1big2", $bbcheck);
$bbcheck=preg_replace("/\[u\](.*?)\[\/u\]/i","u1u2", $bbcheck);
$bbcheck=preg_replace("/\[i\](.*?)\[\/i\]/i","i1i2", $bbcheck);
$bbcheck=preg_replace("/\[b\](.*?)\[\/b\]/i","b1b2", $bbcheck);
$testa = array("b1","i1","u1","big1","small1");
$checka = substr_count($bbcheck,$testa);
$testb = array("b2","i2","u2","big2","small2");
$checkb = substr_count($bbcheck,$testb);
if($checka!=$checkb){
$text = "BB Code Error";
}
return $text;
} function parsepm($text,$sid){
Bookmarks