Using below PHP snippet you can create JSON data. This will come handy when you are creating web services for mobile apps.
1
2
|
$json_data = array ('id'=>1,'name'=>"Mohit");
echo json_encode($json_data);
|
1
2
|
$json_data = array ('id'=>1,'name'=>"Mohit");
echo json_encode($json_data);
|
$tennisArray = array('Djokovic' => 1, 'Federer' => 2,
'Nadal' => 3, 'Murray' => 4);
echo json_encode($tennisArray);
The code above will output the JSON formatted data like this:
{"Djokovic":1,"Federer":2,"Nadal":3,"Murray":4}
Hello Friends! I am Ramana a part time blogger from Hyderabad.