<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>
<?php
$items_list=array(
"0"=>array("name"=>"Biscuit","code"=>"10001","srate"=>"999","prate"=>"1000"),
"1"=>array("name"=>"car","code"=>"10002","srate"=>"229")
);

$data=array("token"=>"8P14ME2W","items_list"=>$items_list);
$json_string = json_encode($data,JSON_PRETTY_PRINT);

echo "<h2>Sample json structures</h2>";

echo "<h2>Example 1  line by line</h2> <pre>";

echo $json_string;

echo "<br><br>";


$bills=array(
"0"=>array(
"invoice_num"=>"001",
"customer"=>"Prathyesh",
"total"=>"1000",
"tax"=>"50",
"details"=>array(
"0"=>array("name"=>"Biscuit","code"=>"10001","qty"=>"2","srate"=>"100","total"=>"200"),
"1"=>array("name"=>"car","code"=>"10002","qty"=>"4","srate"=>"200","total"=>"800"),
"2"=>array("name"=>"cake","code"=>"10003","qty"=>"1","srate"=>"1000","total"=>"1000")
)),

"1"=>array(
"invoice_num"=>"002",
"customer"=>"shilpa",
"total"=>"2000",
"tax"=>"50",
"details"=>array(
"0"=>array("name"=>"Biscuit","code"=>"10001","qty"=>"2","srate"=>"100","total"=>"200"),
"1"=>array("name"=>"car","code"=>"10002","qty"=>"4","srate"=>"200","total"=>"800")
))

);

$data2=array("token"=>"8P14ME2W","bills"=>$bills);
$json_string2 = json_encode($data2,JSON_PRETTY_PRINT);


echo "<h2>Example 2 master and details </h2>";

echo $json_string2;

echo "<br><br>";

/*$array = json_decode( $json_string, true );

print_r($array);*/
?>


<form action="" method="post" enctype="multipart/form-data">
<textarea name="jsaa"></textarea>
<input type="submit" name="save_btn" value="check" />
</form>


</body>
</html>

<?php
if(isset($_POST['save_btn']))
{
$jsaa=$_POST['jsaa'];
$array = json_decode( $jsaa, true );	
print_r($array);
}
?>