PHP JSON Encode square bracket

Viewed 8474

I have a simple JSON array I am trying to encode. Inside of the JSON string I need another array in square brackets. I am unable to figure out how to make the internal brackets square. Any advice?

Here is my code

$data = [ "item" =>  ["id" => "123456", "name" => "adam"]  ];                                                                    
$data_string = json_encode($data);

Here is the output

{"item":{"id":"123456","name":"adam"}}

What I am hoping to get

{"item":["1123","1134","1184"]}
2 Answers
Related