json_decode
(PHP 5 >= 5.2.0, PECL json:1.2.0-1.2.1)
json_decode — Converteşte într-o variabilă un şir reprezentat JSON
Descrierea
mixed json_decode
( string $json
[, bool $assoc
] )
Preia un şir de caractere reprezentat JSON şi îl converteşte într-o variabilă PHP.
Parametri
Valorile întroarse
Întoarce un object, sau dacă parametrul opţional assoc este TRUE, un array asociativ.
Exemple
Example#1 json_decode() exemplu
<?php
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
var_dump(json_decode($json));
var_dump(json_decode($json, true));
?>
Exemplul de mai sus va afişa:
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) }
Note
Istoria schimbărilor
Versiunea | Descriere |
---|---|
5.2.3 | Limita de imbricare a fost mărită de la 20 la 128. |