DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Chara has posted 50 posts at DZone. View Full User Profile

Creating and Parsing JSON Data in PHP

01.26.2014
| 2240 views |
  • submit to reddit
<?php
$json_data = array(
   'id'=>1,'name'=>'jackson','country'=>'usa','office'=>array('google','oracle')
);
echo json_encode
($json_data);

// Result:
// {"id":1,"name":"jackson","country":"usa","office":["google","oracle"]}
?>

This code demonstrates how to create and parse the JSON data format of using array of PHP. It's a very simple code, that allows you to perform this task.