时间:2021-07-01 10:21:17 帮助过:30人阅读
$tree = array ( array ( 'ID' => 1, 'PARENT' => 0, 'NAME' => '祖父', 'CHILD' => array ( array ( 'ID' => 3, 'PARENT' => 1, 'NAME' => '叔伯' ), array ( 'ID' => 4, 'PARENT' => 1, 'NAME' => '父亲', 'CHILD' => array ( array ( 'ID' => 5, 'PARENT' => 4, 'NAME' => '儿子' ) ) ) ) ), array ( 'ID' => 2, 'PARENT' => 0, 'NAME' => '祖母' ) );
你是递归来的,当然应该递归去
$tree = array ( array ( 'ID' => 1, 'PARENT' => 0, 'NAME' => '祖父', 'CHILD' => array ( array ( 'ID' => 3, 'PARENT' => 1, 'NAME' => '叔伯' ), array ( 'ID' => 4, 'PARENT' => 1, 'NAME' => '父亲', 'CHILD' => array ( array ( 'ID' => 5, 'PARENT' => 4, 'NAME' => '儿子' ) ) ) ) ), array ( 'ID' => 2, 'PARENT' => 0, 'NAME' => '祖母' ) );function 递归($ar, $deep=0) { echo str_repeat("\t", $deep) . "
你是递归来的,当然应该递归去
$tree = array ( array ( 'ID' => 1, 'PARENT' => 0, 'NAME' => '祖父', 'CHILD' => array ( array ( 'ID' => 3, 'PARENT' => 1, 'NAME' => '叔伯' ), array ( 'ID' => 4, 'PARENT' => 1, 'NAME' => '父亲', 'CHILD' => array ( array ( 'ID' => 5, 'PARENT' => 4, 'NAME' => '儿子' ) ) ) ) ), array ( 'ID' => 2, 'PARENT' => 0, 'NAME' => '祖母' ) );function 递归($ar, $deep=0) { echo str_repeat("\t", $deep) . "
$data = array( array('ID'=>1, 'PARENT'=>0, 'NAME'=>'祖父'), array('ID'=>2, 'PARENT'=>1, 'NAME'=>'父亲'), array('ID'=>3, 'PARENT'=>1, 'NAME'=>'叔伯'), array('ID'=>4, 'PARENT'=>2, 'NAME'=>'自己'), array('ID'=>5, 'PARENT'=>4, 'NAME'=>'儿子'),);