JSON Funciton in PHP

JSON Funciton in PHP

To convert an associate array to JSON,pass it to json_encode function

$array1 = array("name" => "myName","age" => "23");

To convert JSON to a PHP object,you can use the function json_decode,the first parameter is a JSON string you want to convert,the second parameter is a boolean decide whether to get an associative array back.

$json = '{

array(2) {  
  string(6) "myName"
  string(2) "11"