递归

function getTree($data, $pId)
{
$html = '';
foreach($data as $k => $v)
{
  if($v['cate_ParentId'] == $pId)
  {        //父亲找到儿子
   $html .= "
  • ".$v['cate_Name']; $html .= getTree($data, $v['cate_Id']); $html = $html."
  • "; } } return $html ? '
      '.$html.'
    ' : $html ; } echo getTree($data, 0);

    你可能感兴趣的:(递归)