public static function createElement(DOMDocument $document, $name, array $attributes = []): DOMElement
    {
        $element = $document->createElement($name);

        foreach ($attributes as $attribName => $attribValue) {
            $element->setAttribute($attribName, $attribValue);
        }

        return $element;
    }
public static function createElement(DOMDocument $document, $name, array $attributes = []): DOMElement
    {
        $element = $document->createElement($name);

        foreach ($attributes as $attribName => $attribValue) {
            $element->setAttribute($attribName, $attribValue);
        }

        return $element;
    }
public static function createElement ( DOMDocument $ document , $ name , array $ attributes = [ ] ) : DOMElement { $ element = $ document -> createElement ( $ name ) ; foreach ( $ attributes as $ attribName => $ attribValue ) { $ element -> setAttribute ( $ attribName , $ attribValue ) ; } return $ element ; }
Shortcut for creating an XML element.

@param DOMDocument $document The document used to create the element. It will NOT be modified.
@param string $name Name of the element.
@param array $attributes String-to-string mapping of attributes to set on the element.
@return DOMElement The newly constructed independent DOM element.
Shortcut for creating an XML element .