Habari\Utils::html_attr PHP Method

html_attr() public static method

Create a list of html element attributes from an associative array
public static html_attr ( array $attrs, integer $quote_flag = ENT_COMPAT, string $encoding = 'UTF-8', boolean $decode = true, boolean $double_encode = true ) : string
$attrs array An associative array of parameters
$quote_flag integer Sets what quotes and doublequotes are escaped
$encoding string The encoding of the passed string
$decode boolean Whether or not to unescape any html entities first
$double_encode boolean Whether or not to double escape any html entities
return string The parameters turned into a string of tag attributes
    public static function html_attr($attrs, $quote_flag = ENT_COMPAT, $encoding = 'UTF-8', $decode = true, $double_encode = true)
    {
        $out = '';
        foreach ($attrs as $key => $value) {
            $value = is_array($value) ? implode(' ', $value) : $value;
            if ($value != '') {
                $out .= ($out == '' ? '' : ' ') . $key . '="' . Utils::htmlspecialchars($value, $quote_flag, $encoding, $decode, $double_encode) . '"';
            }
        }
        return $out;
    }