Amit Dhamu

Writes Code

Convert XML to Array

function XML2Array(SimpleXMLElement $parent) {
    $array = array();

    foreach ($parent as $name => $element) {
        ($node = & $array[$name])
            && (1 === count($node) ? $node = array($node) : 1)
            && $node = & $node[];

        $node = $element->count() ? $this->XML2Array($element) : trim($element);
    }

    return $array;
}


Source


xml / array

← If Statements in SASS Git - Change Remote Origin →