Amit Dhamu

Software Engineer

Convert XML to Array

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

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

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

Source


 xml / array

If Statements in SASSGit - Change Remote Origin

Show Comments

Made with by Amit Dhamu.
© MMXX. All rights reserved.