Se usi php > 4.3.3 prova questa regex:
codice:
function ck_brackets($string,$type){
	$rex=array(
	    /*()*/'round'=>'/^[^()]*(\((?:(?>[^()]*)|(?1))+\)[^()]*)*$/'
	    /*[]*/,'square'=>'/^[^\[\]]*(\[(?:(?>[^\[\]]*)|(?1))+\][^\[\]]*)*$/'
	    /*{}*/,'curly'=>'/^[^\{\}]*(\{(?:(?>[^\{\}]*)|(?1))+\}[^\{\}]*)*$/'
	  );
	return preg_match($rex[$type],$string);
}