[snip] > $json = JSON_encode( $root ); [/snip] Update on my test. This works perfectly Robert - thank you very much! But there is one small problem that I am trouble-shooting: it only goes one layer and doesn't progress any further. I suspect it is on this section of code that I am going to add some stuff to to see what is happening. if( !($parents = &$children) ){ break; }