src/HtmlBuilder.php
public function attributes(array $attributes): string
    {
        $html = [];

        // For numeric keys we will assume that the key and the value are the same
        // as this will convert HTML attributes such as "required" to a correct
        // form like required="required" instead of using incorrect numerics.
        foreach ((array) $attributes as $key => $value) {
            if (\is_array($value) && $key !== 'class') {
                foreach ((array) $value as $name => $val) {
                    $element = $this->attributeElement($key.'-'.$name, $val);
                    if (! \is_null($element)) {
                        $html[] = $element;
                    }
                }
            } else {
                $element = $this->attributeElement($key, $value);
                if (! \is_null($element)) {
                    $html[] = $element;
                }
            }
        }

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

        // For numeric keys we will assume that the key and the value are the same
        // as this will convert HTML attributes such as "required" to a correct
        // form like required="required" instead of using incorrect numerics.
        foreach ((array) $attributes as $key => $value) {
            if (\is_array($value) && $key !== 'class') {
                foreach ((array) $value as $name => $val) {
                    $element = $this->attributeElement($key.'-'.$name, $val);
                    if (! \is_null($element)) {
                        $html[] = $element;
                    }
                }
            } else {
                $element = $this->attributeElement($key, $value);
                if (! \is_null($element)) {
                    $html[] = $element;
                }
            }
        }

        return \count($html) > 0 ? ' '.\implode(' ', $html) : '';
    }
Build an HTML attribute string from an array.

@param  array  $attributes

@return string