Create a string of attributes to use in an HTML tag.

@param  array  $attributes An array of keys and values
@return string The attributes with a leading space
486378
public static function attributes(array $attributes = array())
    {
        $text = array();
        foreach ($attributes as $key => $value) {
            //if we have numeric keys (e.g. checked), set the value as
            //the $key (e.g. checked="checked"), but only if it
            //doesn't exist already
            if (is_numeric($key)) {
                $value = htmlspecialchars($value);
                if (!isset($attributes[$value])) {
                    $text[] = $value . '="' . $value . '"';
                }
                continue;
            }
            $text[] = $key . '="' . htmlspecialchars($value) . '"';
        }

        return empty($text) ? '' : ' ' . implode(' ', $text);
    }
218390
protected function prepareAttributes(array $attributes)
    {
        $attributesCollected = '';

        foreach ($attributes as $attribute => $value) {
            // Check value-less attributes to be embedded properly
            if ($value === null) {
                $attributesCollected .= ' '.$attribute;
            } else {
                $value = (is_array($value)) ? $value[0] : $value;
                $attributesCollected .= ' '.$attribute.'="'.$value.'"';
            }
        }

        return $attributesCollected;
    }
1287816
public static function renderAttributes(array $attributes)
    {
        $html = [];
        foreach ($attributes as $key => $value) {
            $escaped = htmlentities($value, ENT_QUOTES, 'UTF-8', false);
            $html[] = is_numeric($key) ?
                ($escaped . '="' . $escaped . '""')
                :
                ("$key=\"$escaped\"");
        }
        return count($html) > 0 ? ' ' . implode(' ', $html) : '';
    }
568816
private function HtmlAttributes($attributes)
    {
        $formatted = join(' ', array_map(function ($key) use ($attributes) {
            if (is_bool($attributes[$key])) {
                return $attributes[$key] ? $key : '';
            }
            return $key . '="' . $attributes[$key] . '"';
        }, array_keys($attributes)));
        return $formatted;
    }
467156
protected static function getAttributesString($attributes)
    {
        $str = '';
        if (is_array($attributes)) {
            $charset = self::getOption('charset');
            foreach ($attributes as $key => $value) {
                $str .= ' ' . $key . '="' . htmlspecialchars($value, ENT_QUOTES, $charset) . '"';
            }
        }
        return $str;
    }
897165
public function attributes(array $attributes)
    {
        foreach ($attributes as $attribute => &$data) {
            $data = implode(' ', (array) $data);
            $data = $attribute . '="' . htmlspecialchars($data, ENT_QUOTES, 'UTF-8') . '"';
        }

        return empty($attributes) ? '' : ' ' . implode(' ', $attributes);
    }
1096913
public function createElement(array $attributes)
    {
        $element = $this->ownerDocument->createElement($this->element);

        $name = null;
        foreach ($attributes as $key => $value) {
            $element->setAttribute($key, $value);
        }

        $this[] = $element;

        return $element;
    }
802985
private function generateAttribute(string $attribute, array $values = []): string
    {
        if (! is_numeric($attribute)) {
            return sprintf(
                '%s="%s"',
                $attribute,
                htmlentities(trim(implode(' ', $values)))
            );
        }

        return implode(' ', $values);
    }
1025413
protected function parseAttributes(array $attributes)
	{
		if (isset($attributes['class'])) {
			if (is_string($attributes['class'])) {
				$attributes['class'] = explode(' ', $attributes['class']);
			}
		} else {
			$attributes['class'] = [];
		}

		return $attributes;
	}
115048
protected function generateAttributes(array $attributes)
	{
		if (isset($attributes['style']) && is_array($attributes['style']))
		{
			$attributes['style'] = $this->generateStyle($attributes['style']);
		}

		ksort($attributes);
		$xsl = '';
		foreach ($attributes as $attrName => $attrValue)
		{
			$innerXML = (strpos($attrValue, '<xsl:') !== false) ? $attrValue : AVTHelper::toXSL($attrValue);

			$xsl .= '<xsl:attribute name="' . htmlspecialchars($attrName, ENT_QUOTES, 'UTF-8') . '">' . $innerXML . '</xsl:attribute>';
		}

		return $xsl;
	}
411462
protected function parseHrefAttributes(?array $attributes) : ?string
    {
        if (empty($attributes)) {
            return null;
        }

        if (isset($attributes['target']) && $attributes['target'] === '_blank') {
            if (!isset($attributes['rel'])) {
                $attributes['rel'] = 'noreferrer noopener';
            }
        }

        $extra = [];

        foreach ($attributes as $attr => $value) {
            $extra[] = $attr . '="' . $value . '"';
        }

        return ' ' . implode(' ', $extra);
    }
861970
public static function attributes($attributes)
    {
        $buffer = '';

        foreach ($attributes as $name => $value) {
            $buffer .= ' ' . $name . '="' . static::attributeValue($value) . '"';
        }

        return $buffer;
    }
1219527
public function buildTagAttributes(array $attributes)
	{
		$html = array();

		foreach ($attributes as $key => $value)
		{
			if (is_null($value))
				continue;

			if (is_numeric($key))
				$key = $value;

			$html[] = $key . '="' . htmlentities($value, ENT_QUOTES, 'UTF-8', false) . '"';
		}

		return (count($html) > 0) ? ' ' . implode(' ', $html) : '';
	}
100568
public static function attrsToHtml(array $attributes)
    {
        $attrs = [];

        foreach ($attributes as $key => $value) {
            $element = is_numeric($key) ?
                (string)$value :
                (is_null($value) ? (string)$key : $key . '="' . e($value) . '"');
            if (!empty($element)) {
                $attrs[] = $element;
            }
        }

        return count($attrs) ? ' ' . implode(' ', $attrs) : '';
    }
749145
public function getHtml(array $attributes = []): string
    {
        $result = '';
        foreach ($this->radioButtons as $radioButton) {
            $result .= $radioButton->getHtml($attributes) . htmlspecialchars($radioButton->getLabel());
        }

        return $result;
    }
1289858
public function getHtml(array $attributes = []): string
    {
        if ($this->minimumValue !== null) {
            $attributes['min'] = $this->minimumValue;
        }

        if ($this->maximumValue !== null) {
            $attributes['max'] = $this->maximumValue;
        }

        return parent::getHtml($attributes);
    }
17448
protected function attributes($attributes)
    {
        $html = array();
        foreach ((array) $attributes as $key => $value)
        {
            $element = $this->attributeElement($key, $value);

            if ( ! is_null($element)) $html[] = $element;
        }

        $output = count($html) > 0 ? ' '.implode(' ', $html) : '';

        return trim($output);
    }