public function bbcode($text) { $decoda = new Decoda\Decoda($text); $decoda->defaults(); $decoda->setStrict(false); // $decoda->removeFilter('Video'); $decoda->removeHook('Censor'); //$decoda->removeFilter('Url'); $html = $decoda->parse(); // $errors = $decoda->getErrors(); // foreach($errors as $error) { // $string = ""; // foreach($error as $key => $value) { // $string = $key . ":" . $value . ", "; // } // error_log($string); // } // print_r($errors); $nesting = array(); $closing = array(); $scope = array(); $errors = array(); foreach ($decoda->getErrors() as $error) { switch ($error['type']) { case Decoda\Decoda::ERROR_NESTING: $nesting[] = $error['tag']; break; case Decoda\Decoda::ERROR_CLOSING: $closing[] = $error['tag']; break; case Decoda\Decoda::ERROR_SCOPE: $scope[] = $error['child'] . ' in ' . $error['parent']; break; } } if (!empty($nesting)) { $errors[] = sprintf('The following tags have been nested in the wrong order: %s', implode(', ', $nesting)); } if (!empty($closing)) { $errors[] = sprintf('The following tags have no closing tag: %s', implode(', ', $closing)); } if (!empty($scope)) { $errors[] = sprintf('The following tags can not be placed within a specific tag: %s', implode(', ', $scope)); } foreach ($errors as $error) { $string = '<div class="alert alert-error">'; $string .= $error; $string .= '</div>'; echo $string; } return $html; // return $decoda->parse(); // return $text; }