PHP Json Encode
Write a php program to loop over the json data
Suppose, you have the following json data.
[
{
"name" : "John Garg",
"age" : "15",
"school" : "Ahlcon Public school"
},
{
"name" : "Smith Soy",
"age" : "16",
"school" : "St. Marie school"
},
{
"name" : "Charle Rena",
"age" : "16",
"school" : "St. Columba school"
}
]
Solution
PHP allows us to easily convert JSON to arrays. PHP provides predefined functions to easily encode and decode json string into php array. The following program converts the json string into array and loop over them.
Output of the above code