Skip to content

Instantly share code, notes, and snippets.

@Sergic
Created November 14, 2014 10:52
Show Gist options
  • 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