Answer the question
In order to leave comments, you need to log in
How to create json array with another array?
Hello Uv. Experts ask for your help.
You need to create a JSON array so that the output would look like this:
users: (6) [{"id":1,"login":'Admin'}, null, null, null, null, null]
route: true
spectators: null
users: (6) [{"id":1,"login":'Admin'}, {"id":2,"login":'NickLogin'}, null, null, null, null]
Answer the question
In order to leave comments, you need to log in
The following PHP array is converted into the JSON you need:
<?php
$json = [
[
["id"=>1,
"login"=>'Admin'
],
null,
null,
null,
null,
null
],
'route' => true,
'spectators' => null
];
echo json_encode($json);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question