
The code below shows how you can use json_decodeĀ () to decode a JSON object into a PHP object.
The Code
1 2 3 4 5 6 7 8 9 |
<?php $jsonobj = '{"Banana":"Yellow","Apple":"Red","Pear":"Green"}'; $obj = json_decode($jsonobj); echo $obj->Banana; //prints yellow echo $obj->Apple; //prints red echo $obj->Pear; //prints green ?> |