php - How to create JSON object with array of nested arrays for multipletimes and multiple times? -
$data=array ( "maths" : [ { "name" : "ramesh", // first element "marks" : 67, "age" : 23 }, { "name" : "mayur", // second element "marks" : 65, "age" : 21 } ], "science" : [ { "name" : "ram", // first element "marks" : 56, "age" : 27 }, { "name" : "santosh", // second element "marks" : 78, "age" : 41 } ] );
you can create $data
, encode json this
<?php $data = array ( "maths" => array( array( "name" => "ramesh", // first element "marks" => 67, "age" => 23 ), array( "name" => "mayur", // second element "marks" => 65, "age" => 21 ) ), "science" => array( array( "name" => "ram", // first element "marks" => 56, "age" => 27 ), array( "name" => "santosh", // second element "marks" => 78, "age" => 41 ) ) ); echo json_encode($data);
Comments
Post a Comment