我有一个reccuring函数,我想用正确的语法再次调用它如何做到这一点?我在数据库中有一个,如果它是一个国家,它持有V:并且它的格式为Col1 CountryName; col1 如果它是一个城市,它没有 V:如果它是一个国家/地区的地区,它有 V: 所以这种递归必须直到我们在数据库中得到一个国家的城市 Country= V:area1, V:area2...Area1=City1 或另一个 V:area ant,直到我们得到城市名称。到目前为止,我在这里做了什么,我是closo,但我不知道如何再次调用相同的函数
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
}
}
编辑:闭上括号
$aeroPole1=array_unique($aeroPole1);
return $aeroPole1;
else
{
$aeroPole1=explode(",",$d);
return $aeroPole1;
}
另一种情况,如果它没有 v:
你可以试试这个
结束后//foreach
$aeroPole1=array_unique($aeroPole1);
return $aeroPole1;
唯一的是没有任何重复项,然后返回函数