Q:

Write a PHP script which decodes the following JSON strin

0

Write a PHP script which decodes the following JSON string.

Sample JSON code :
{"Title": "The Cuckoos Calling",
"Author": "Robert Galbraith",
"Detail": {
"Publisher": "Little Brown"
}}

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

<?php
function w3rfunction($value,$key)
{
echo "$key : $value"."\n";
}
$a = '{"Title": "The Cuckoos Calling",
"Author": "Robert Galbraith",
"Detail":
{ 
"Publisher": "Little Brown"
 }
  }';
$j1 = json_decode($a,true);
array_walk_recursive($j1,"w3rfunction");
?>

Sample Output:

Title : The Cuckoos Calling                                 
Author : Robert Galbraith                                   
Publisher : Little Brown

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now