group and sort Hierarchicaly array in php

A

Anonymous

Guest
i have table in mysql like this :
Code:
staff_id  |    id
10           |   1
1001       |   2
12           |   3
1201	|   4
1002	|   5
1202	|   6
120101	|   7
120201  |   8
13           |   9
...
i want query in php Or Mysql For output array like this
Code:
-10
        --1001
        --1002

-12

        --1201
                    --- 120101
        --1202
                   --- 120201
-13
Thanks !
 
so you have a task... and what did you try yourself to achieve this?
 
Is this what you want?

Code:
<?php

function query(){
 return [10=>[1001,1002],
         12=>[1201=>[120101],
              1202=>[120201]],
         13=>[]
         ];
}

var_dump (query());
 
Back
Top