SQL result to PHP multidimensional array -


I am retrieving some classified data from an Oracle database using the" Connect by "function.

Then I look like a PHP array popup with the result of my question:

  while ($ row_branches = oci_fetch_array ($ query_tree)) {$ tree [] = '$ String_branches [' id '],' parent '= & gt; $ row_branche [' PARENT '],' data '= & gt; htmlspecialchars ($ row_branches [' name ' ]), 'Level' = & gt; $ row_branches ['level']); }  

The field ID is the unique id of the field is the parent of the PARENT parent's field area field level is the level of the item in the hierarchy of the item's name.

I would rather have a multidimensional array because my goal is to use the PHP function json_decode ().

The depth of the hierarchy is never known in advance.

So my question is:.

How can I populate a multidimensional array with the result of my question

Thank you in advance for your answer

Try it

  function adj_tree (& $ tree, $ item) {$ I = $ item ['id']; $ P = $ item ['parent']; $ Tree [$ i] = released ($ tree [$ i])? $ Item + $ tree [$ i]: $ item; $ Tree [$ p] ['_ kids'] [] = & amp; $ Tree [$ i]; } $ Tree = array (); While ($ line = oci_fetch_array ($ query_tree)) {adj_tree ($ tree, $ line);  

Comments

Popular posts from this blog

objective c - iPhone and it's wireless area -

unix - Listing all shared memory segments used by a process on AIX5.3+ -

tsql - Correct sql/hql query (aggregate in where clause) -