Problem with passing values from php to JavaScript array

I would like to ask the expert that the format of the front-end JavaScript array is: var menu= [{id: "11", text: "menu 1", children: [{id: "11", text: "sub-menu 1"}, {id: "112", text: "sub-menu 2"}]}, and how to use php to transfer values in the background?

Php
Mar.15,2021

the front and back end values are transmitted in json format
the original array format should be

array (
  0 => 
  array (
    'id' => '11',
    'text' => '1',
    'children' => 
    array (
      0 => 
      array (
        'id' => '111',
        'text' => '1',
      ),
      1 => 
      array (
        'id' => '112',
        'text' => '2',
      ),
    ),
  ),
)

format it with json_encode and return it
the data returned should be

[{
    "id": "11",
    "text": "1",
    "children": [{
        "id": "111",
        "text": "1"
    }, {
        "id": "112",
        "text": "2"
    }]
}]

convert json_encode to json string

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3808b-e62f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3808b-e62f.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?