7
json_encode / json_decode - mengembalikan stdClass daripada Array di PHP
Perhatikan skrip kecil ini: $array = array('stuff' => 'things'); print_r($array); //prints - Array ( [stuff] => things ) $arrayEncoded = json_encode($array); echo $arrayEncoded . "<br />"; //prints - {"stuff":"things"} $arrayDecoded = json_decode($arrayEncoded); print_r($arrayDecoded); //prints - stdClass Object ( [stuff] => things ) Mengapa PHP mengubah Objek JSON menjadi kelas? Seharusnya …