codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
<?php $a = array( 'Alpha' => array('Red' => 'one', 'Blue' => 'two'), 'Bravo' => array('Blue' => 'three')); function convert_array($from){ if(!is_array($from)){ return false; } $to = array(); foreach($from as $k=>$v){ $to[] = array( 'title' => $k, 'children' => convert_array($v) ); } return $to; } print_r(convert_array($a));
Private
[
?
]
Run code
Submit