Possible Duplicate:
PHP : Create array for JSON
I need to output data in the following JSON format.
Output :
[
{
"name": "jake",
"age": "20"
}
]
In the following code, i need to set the key and value pairs in a way where it will give the above JSON output. How could i do this ?
Code :
$result = array();
$key = array("name", "age");
$value = array("jake", "20");
while($i>2)
{
$result [] = HERE I NEED TO SET <key : value> COMBINATION, I NEED IT TO SET IN A WAY IT WILL GIVE THE FORMAT OF THE JSON OUTPUT GIVEN ABOVE.
}
echo json_encode($result );