PHP program to decode the JSON string into an associative array

bookmark

<?php
//PHP program to decode the Json string into 
//associative array.
$json = '{"Id1":101,"Id2":102,"Id3":103,"Id4":104}';
$ids = json_decode($json);

foreach ($ids as $key => $value)
{
    print ("Key: " . $key . " Value: " . $value . "<br/>");
}
?>


Output
Key: Id1 Value: 101
Key: Id2 Value: 102
Key: Id3 Value: 103
Key: Id4 Value: 104