[Solved] PHP generate json – list of categories [closed]


You can use an multi-dimensional array with the json_encode function to achieve this structure.

$var = array(
“contacts” => array (
array(
“id” => 1,
“name” => “foo”
),
array(
“id” => 2,
“name” => “bar”
)
)
);

echo json_encode($var);

4

solved PHP generate json – list of categories [closed]