Skip to content

Instantly share code, notes, and snippets.

@Sergic
Created November 14, 2014 10:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Sergic/cc11b08c0a030989be84 to your computer and use it in GitHub Desktop.
Save Sergic/cc11b08c0a030989be84 to your computer and use it in GitHub Desktop.
<?php
//function build tree --- recursive
function show_tree( &$data, $point, $str ){
//reset($data);
$str .= "&nbsp;&nbsp;&nbsp;";
while ( list( $index, $point_data ) = each( $data ) ){
if ( $point_data[ 'parent_id' ] == $point ){
echo $str.$point_data[ 'name' ].'<br>';
unset( $data[ $index ] );
show_tree( $data, $point_data[ 'id' ], $str );
reset( $data );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment