[PHP] transformer un objet SimpleXML en tableau (array)

function simplexml2array($simplexml) 
{
    $result = array();
    if(!$simplexml) return $result;
    foreach($simplexml->children() as $cle=>$value) {
         $result[(string) $cle] = $value->hasChildren() ? simplexml2array($value) : (string) $value;
    }
    return $result;
}

categorie: