1

我有一个递归函数,我想用正确的语法再次调用它怎么做?我在数据库中有一个国家,如果它拥有 V: 并且它的格式为 Col1 CountryName; col1 如果它是一个城市,它没有 V:如果它是国家的一个地区,它有 V:所以这个递归必须是直到我们在数据库中获得一个国家的城市 Country= V:area1, V:area2.. .Area1=City1 或另一个 V:area 蚂蚁,所以直到我们得到城市名称..这是我到目前为止所做的事情,我很接近,但我不知道如何再次调用相同的函数

   function recur($d,$rek,&$aeroPole1)
  {
if(substr_count( $d, 'V:'))
  {

    $aeroPole=preg_replace('"V:"','',$d); 

    $aeroPole=explode(",",$aeroPole);

    foreach($aeroPole as $ap)
    {
          $mysqliObj3 = new mysqli('localhost','usr','pass', 'trevo');
          $comand6="SELECT * FROM `CC` WHERE name='".$ap."';";  //  name='".$RuleD[0]."';";
          $QueryObj6 = $mysqliObj3->query($comand6, MYSQLI_USE_RESULT);

          $dArea=$QueryObj6->fetch_assoc();
          $QueryObj6->close();


          if($dArea!="")
          {$rek+=1;
             $aeroPole1=array_merge($aeroPole1,recur((string)$dArea["airport_codes"],$rek,$aeroPole1));

            $fore++;

        }

    }//foreach




}
}

编辑:关闭括号

4

2 回答 2

1
     $aeroPole1=array_unique($aeroPole1);
    return $aeroPole1;

else
{
     $aeroPole1=explode(",",$d);


  return $aeroPole1;
}

另一种情况,如果它没有 v:

于 2013-02-02T12:04:02.720 回答
0

你可以试试这个

//结束后foreach

$aeroPole1=array_unique($aeroPole1);
    return $aeroPole1;

唯一的是没有任何重复,然后你返回函数

于 2013-02-02T12:01:12.330 回答