src/Type/Xml.php
protected static function loopEncode($data, $domElement)
    {
        if (is_array($data)) {
            foreach ($data as $index => $mixedElement) {
                if (is_int($index)) {
                    if ($index == 0) {
                        $node = $domElement;
                    } else {
                        $node = new DOMElement($domElement->tagName);
                        $domElement->parentNode->appendChild($node);
                    }
                } else {
                    $node = new DOMElement($index);
                    $domElement->appendChild($node);
                }
                 
                self::loopEncode($mixedElement, $node);
            }
        } else {
            $domElement->appendChild(new DOMText($data));
        }

        return $domElement;
    }
protected static function loopEncode($data, $domElement)
    {
        if (is_array($data)) {
            foreach ($data as $index => $mixedElement) {
                if (is_int($index)) {
                    if ($index == 0) {
                        $node = $domElement;
                    } else {
                        $node = new DOMElement($domElement->tagName);
                        $domElement->parentNode->appendChild($node);
                    }
                } else {
                    $node = new DOMElement($index);
                    $domElement->appendChild($node);
                }
                 
                self::loopEncode($mixedElement, $node);
            }
        } else {
            $domElement->appendChild(new DOMText($data));
        }

        return $domElement;
    }
protected static function loopEncode ( $ data , $ domElement ) { if ( is_array ( $ data ) ) { foreach ( $ data as $ index => $ mixedElement ) { if ( is_int ( $ index ) ) { if ( $ index == 0 ) { $ node = $ domElement ; } else { $ node = new DOMElement ( $ domElement -> tagName ) ; $ domElement -> parentNode -> appendChild ( $ node ) ; } } else { $ node = new DOMElement ( $ index ) ; $ domElement -> appendChild ( $ node ) ; } self :: loopEncode ( $ mixedElement , $ node ) ; } } else { $ domElement -> appendChild ( new DOMText ( $ data ) ) ; } return $ domElement ; }
Lets loop through our data
@param  mixed                  $data       Data to encode
@param  DOMDocument|DOMElement $domElement Document to initialize and then it'll call itself with inner Element(s)
@return DOMDocument
Lets loop through our data