To Create and Parse JSON data in PHP :
We can use json_encode() function of PHP to create JSON data format. Below is the PHP snippet to create the JSON data format of given array of PHP :

Example :

 <?php
                               
$json_data = array(
	        "id" => 1,
	     	"name" => "Rahul Yadav",
	     	"country" => "India",
	     	"email" => "admin@codephponline.com",
	     	"frameworks" => array(
		                  "Codeigniter",
		                  "Laravel"
		                  )
             );
$json_string = json_encode($json_data);
echo $json_string;

 ?>
 
 
 /*

 Output :

 {"id":1,"name":"Rahul Yadav","country":"India","email":"admin@codephponline.com","frameworks":["Codeigniter","Laravel"]}

 */

  
We can use json_decode() function of PHP to parse the JSON data. Below code will parse the JSON data into PHP arrays.

Example :

 <?php
                               
$json_string='{"id":1,"name":"Rahul Yadav","country":"India","email":"admin@codephponline.com","frameworks":["Codeigniter","Laravel"]}';
$obj=json_decode($json_string);
//print the parsed data
echo $obj->id."
"; // displays 1 echo $obj->name."
"; // displays Rahul Yadav echo $obj->country."
"; // displays India echo $obj->email."
"; //displays admin@codephponline.com echo $obj->frameworks[0]."
"; // displays Codeigniter echo $obj->frameworks[1]."
"; // displays Laravel ?> /* Output : 1 Rahul Yadav India admin@codephponline.com Codeigniter Laravel */