json_decode
(no version information, might be only in CVS)
json_decode -- Décode une chaîne JSON
Description
mixed
json_decode ( string json [, bool assoc] )
Récupère une chaîne encodée JSON et la convertie en une variable PHP.
Liste de paramètres
- json
La chaîne json à décoder.
- assoc
Lorsque ce paramètre vaut TRUE, l'objet retourné sera converti en un
tableau associatif.
Valeurs de retour
Retourne un objet ou, si le paramètre optionnel
assoc vaut TRUE, un tableau associatif.
Exemples
Exemple 1. Exemple avec json_decode()
<?php $json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json)); var_dump(json_decode($json, true));
?>
|
L'exemple ci-dessus va afficher : object(stdClass)#1 (5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
}
array(5) {
["a"] => int(1)
["b"] => int(2)
["c"] => int(3)
["d"] => int(4)
["e"] => int(5)
} |
|