欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  php教程

循环递归-数组,循环递归数组

程序员文章站 2022-04-23 16:36:50
...

循环递归-数组,循环递归数组

private function Fndotoarea($oid){
  $oid = $this->CHTID($oid);
  $arrtaff = array();
  $arrt =array();
  $arrr = array();
  foreach($this->select("SELECT areaname , tid FROM otoarea WHERE oid = '".$oid."' " ) as $ks){
    $arrr= Array("node"=>$ks["areaname"],"value"=>$ks["tid"]);
  foreach ($this->select("select areaname , tid FROM otoarea WHERE oid = '".$ks["tid"]."' ") as $kr){
    $arrr['nodes'][] = Array("node"=>$kr["areaname"],"value"=>$kr["tid"]);
}
  $nodes = $this->Fndotoarea($ks["tid"]);
  if(!empty($nodes)){
    $arrr["nodes"] = $nodes;
}
  array_push($arrtaff, $arrr);
}
  return $arrtaff;
}

/*-------------------------------------------------------------*/

private function Fndotoarea($oid){
$oid = $this->CHTID($oid);
$arrtaff = array();
$arrt =array();
$arrr = array();
foreach($this->select("SELECT areaname , tid FROM otoarea WHERE oid = '".$oid."' " ) as $ks){
$arrr= Array("node"=>$ks["areaname"],"value"=>$ks["tid"]);
foreach ($this->select("select areaname , tid FROM otoarea WHERE oid = '".$ks["tid"]."' ") as $kr){
$arrr['nodes'][] = Array("node"=>$kr["areaname"],"value"=>$kr["tid"]);
}
$nodes = $this->Fndotoarea($ks["tid"]);
if(!empty($nodes)){
$arrr["nodes"] = $nodes;
}
array_push($arrtaff, $arrr);
}
return $arrtaff;
}

相关标签: 递归函数