How to Make This Type of json In php

{
  "Students": {
    "Name": "John",
    "Id": "123"
  },
   {
    "Name": "Mickel",
    "Id": "4331"
  },
  "Status": "Success"
}

And I Want To Make Like This In PHP How I Can Make It

That is not valid JSON. You can try it out here

Assuming you want valid json output then this will work

$result = [
  'Students' => [
      ['Name' => 'John', 'id' => 123],
      ['Name' => 'Mickel', 'id' => 4331]
  ],
  'Status' => 'Success'
];

echo json_encode($result);
{
	"Students": [{
		"Name": "John",
		"id": 123
	}, {
		"Name": "Mickel",
		"id": 4331
	}],
	"Status": "Success"
}
2 Likes

i Have All Data In MYSQL How To Do It

Sponsor our Newsletter | Privacy Policy | Terms of Service