value array namespace Enlighter\skltn; class HtmlUtil{ // generate a HTML tag and escape attribute/value pairs + content public static function generateTag($name, $htmlAttributes = array(), $selfClosing=true, $content=false){ // generate tag start $html = '<'.strtolower($name); // generate html attributes foreach ($htmlAttributes as $key=>$value){ $html .= ' '.esc_attr($key).'="'.esc_attr($value).'"'; } // self closing and no content ? if ($selfClosing === true){ // add content ? if ($content !== false){ $html .= '>' . esc_html($content) . ''; // just close it }else{ $html .= ' />'; } }else{ // add content ? if ($content !== false){ $html .= '>' . esc_html($content); }else{ $html .= '>'; } } return $html; } }