-2

Model JSON: https://dl.dropboxusercontent.com/s/vjq9j5gwkbrly3y/data.json

How can I generate the above JSON using PHP, including the separate categories in to the above model?

I need help to separate the above categories for JSON. Do I have to do several selects?

1
  • Not sure what you mean by do i have to do several selects....as you're not mentioning MYSQL at all , youre asking how to generate JSON with php Commented Jun 27, 2014 at 22:01

1 Answer 1

2

Just build your arrays,

    $array = array("Restaurants"=>array(
      array("ID"=>23,"name"=>"test","example"=>"ex"),
      array("ID"=>23,"name"=>"test","example"=>"ex"),
      array("ID"=>23,"name"=>"test","example"=>"ex")
     ),
    "Categories"=>array(
      array("cat"=>"example","ex"=>"example"),
      array("cat"=>"example","ex"=>"example")
     )
     );

Then use json_encode

    echo json_encode($array);

EXAMPLE

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.