//1º posibilidad $tema = substr($var, 5, -6); //2º posibilidad preg_match("/\[xat\]([^\[]+)\[\/xat\]/", $var, $tema); $tema = $tema[1];