Récupération données avec json_decode

WRInaute impliqué
Salut à tous et bonnes fêtes de fin d'année ;)

Je souhaite récupérer les données d'un fichier xml, pour cela j'utilise ce code :
Code:
$xml = simplexml_load_file($url_fichier);
$json_string = json_encode($xml);
$result_array = json_decode($json_string, TRUE);
Lorsque je fais var_dump($result_array); j'obtiens ce code :
Code:
array(3) { ["STATUS"]=> string(7) "SUCCESS" ["ERROR "]=> array(2) { ["ERROR_CODE"]=> array(0) { } ["ERROR_MSG"]=> array(0) { } } ["REPORT 1"]=> array(1) { ["REPORT2 "]=> array(101) { ["MESSAGE"]=> array(0) { } ["LENGTH"]=> string(21) "5.93 " ["WIDTH"]=> string(21) "5.97 " ["DEPTH"]=> string(21) " 3.70 " etc... } } }
Comment récupérer la valeur 5.93 de ["LENGTH"] ?

J'ai essayé ce type de code mais ça marche pas : print $result_array->{'["LENGTH"]'};

Merci pour votre aide.
 
WRInaute accro
Si tu es perdu:
PHP:
echo '<pre>';
print_r($result_array);
echo '</pre>';

Si tu t'es pas trompé dans le copier/coller (parce que la clef REPORT2 avec un espace c'est bizarre):
PHP:
$result_array['REPORT 1']['REPORT2 ']['LENGTH']
 
WRInaute impliqué
Merci spout ça marche nickel :)

Oui je me suis trompé dans le copier/coller, il y a bien un espace en trop dans la clef REPORT2.
 
Discussions similaires
Haut