A common use of JSON is to read data from a web server, and display the data in a web page. This chapter will teach you how to exchange JSON data between the client and a PHP server.
- json_encode()
- json_decode()
json_encode() ( Convert array into json ) <?php $age = array("Peter"=>35, "Ben"=>37, "Joe"=>43); echo json_encode($age); ?>
json_decode() ( Convert json into array ) <?php $jsonobj = '{"Peter":35,"Ben":37,"Joe":43}'; var_dump(json_decode($jsonobj)); ?>