function wrapTag($tag, $html, $options) { // Wrap the tags defined in the options array (like b, i, font... tags) if (!empty($options)) { foreach ($options as $k => $v) { if (is_array($v)) { $html = wrapTag($k, "{$html}", $v); } } } // wrap the HTML content with the passed tag $return = "<{$tag} "; if (!empty($options)) { foreach ($options as $k => $v) { if (!is_array($v)) { $return .= " {$k}=" . '"' . $v . '"'; } } } return $return . ">" . $html . "</{$tag}>"; }
/** * return the HTML code of the value wrap with the tag $tag. This method handle options (general and specific) * @param $tag * @param $value * @param $options * @return the HTML wrapped code */ private function wrap($tag, $value, $options) { if (empty($options[$tag])) { $options[$tag] = array(); } if (is_array($value)) { if (isset($value["options"])) { // The options of a specific entity overwrite the general options $options[$tag] = $value["options"]; } if (isset($value["value"])) { $value = $value["value"]; } else { $value = ""; } } return wrapTag($tag, $value, $options[$tag]); }