src/bbn/x.php
public static function get_tree($ar){
    $res = [];
    foreach ( $ar as $k => $a ){
      $r = ['text' => $k];
      if ( \is_object($a) ){
        $a = self::to_array($a);
      }
      if ( \is_array($a) ){
        $r['items'] = self::get_tree($a);
      }
      else if ( \is_null($a) ){
        $r['text'] .= ': null';
      }
      else if ( $a === false ){
        $r['text'] .= ': false';
      }
      else if ( $a === true ){
        $r['text'] .= ': true';
      }
      else {
        $r['text'] .= ': '.(string)$a;
      }
      array_push($res, $r);
    }
    return $res;
  }
public static function get_tree($ar){
    $res = [];
    foreach ( $ar as $k => $a ){
      $r = ['text' => $k];
      if ( \is_object($a) ){
        $a = self::to_array($a);
      }
      if ( \is_array($a) ){
        $r['items'] = self::get_tree($a);
      }
      else if ( \is_null($a) ){
        $r['text'] .= ': null';
      }
      else if ( $a === false ){
        $r['text'] .= ': false';
      }
      else if ( $a === true ){
        $r['text'] .= ': true';
      }
      else {
        $r['text'] .= ': '.(string)$a;
      }
      array_push($res, $r);
    }
    return $res;
  }
public static function get_tree ( $ ar ) { $ res = [ ] ; foreach ( $ ar as $ k => $ a ) { $ r = [ 'text' => $ k ] ; if ( \ is_object ( $ a ) ) { $ a = self :: to_array ( $ a ) ; } if ( \ is_array ( $ a ) ) { $ r [ 'items' ] = self :: get_tree ( $ a ) ; } else if ( \ is_null ( $ a ) ) { $ r [ 'text' ] .= ': null' ; } else if ( $ a === false ) { $ r [ 'text' ] .= ': false' ; } else if ( $ a === true ) { $ r [ 'text' ] .= ': true' ; } else { $ r [ 'text' ] .= ': ' . ( string ) $ a ; } array_push ( $ res , $ r ) ; } return $ res ; }
Returns the given array or object as a tree structure ready for a JS tree.

```php
\bbn\x::hdump(\bbn\x::get_tree([['id' => 1,'name' => 'Andrew','fname' => 'Williams','children' =>[['name' => 'Emma','age' => 6],['name' => 'Giorgio','age' => 9]]], ['id' => 2,'name' => 'Albert','fname' => 'Taylor','children' =>[['name' => 'Esther','age' => 6],['name' => 'Paul','age' => 9]]], ['id' => 3,'name' => 'Mike','fname' => 'Smith','children' =>[['name' => 'Sara','age' => 6],['name' => 'Fred','age' => 9]]]]));
/* array [
[ "text" => 0, "items" => [ [ "text" => "id: 1", ], [ "text" => "name: Andrew", ], [ "text" => "fname: Williams", ], [ "text" => "children", "items" => [ [ "text" => 0, "items" => [ [ "text" => "name: Emma", ], [ "text" => "age: 6", ], ], ], [ "text" => 1, "items" => [ [ "text" => "name: Giorgio", ], [ "text" => "age: 9", ], ], ], ], ], ], ], [ "text" => 1, "items" => [ [ "text" => "id: 2", ], [ "text" => "name: Albert", ], [ "text" => "fname: Taylor", ], [ "text" => "children", "items" => [ [ "text" => 0, "items" => [ [ "text" => "name: Esther", ], [ "text" => "age: 6", ], ], ], [ "text" => 1, "items" => [ [ "text" => "name: Paul", ], [ "text" => "age: 9", ], ], ], ], ], ], ], [ "text" => 2, "items" => [ [ "text" => "id: 3", ], [ "text" => "name: Mike", ], [ "text" => "fname: Smith", ], [ "text" => "children", "items" => [ [ "text" => 0, "items" => [ [ "text" => "name: Sara", ], [ "text" => "age: 6", ], ], ], [ "text" => 1, "items" => [ [ "text" => "name: Fred", ], [ "text" => "age: 9", ], ], ], ], ], ], ], ]
```

@param array $ar
@return array
Returns the given array or object as a tree structure ready for a JS tree .