瀏覽二叉樹時,我想返回一個遞歸函數數組。特別是當二進制樹中的元素到達條件(if語句)被插入到數組中時。畢竟,該元素返回所有的數組。我的代碼不工作!??從遞歸返回數組--PHP
function tree_view($clear_static = false,$conn,$index)
{
static $count = 0;
if ($clear_static) {
$count = 0;
}
$q=mysql_query("SELECT user_id FROM thanhvien WHERE gioithieu='".$index."'",$conn);
while($arr=mysql_fetch_assoc($q))
{
if (truongban($conn,$arr["user_id"],1)==true){
$mang[$count]=$arr["user_id"];
$count++;
}
tree_view(false,$conn,$arr["user_id"]);
}
return $mang;
}
$mang1=tree_view (true,$conn,anloc);
print_r($mang1);
你想真正迴歸「的遞歸函數陣」?不只是簡單的數據? – SteAp 2012-02-25 00:30:28
是的!即時通訊真的返回我的功能陣列! Plz幫我 – hitachitellme 2012-02-25 11:10:34
你想返回你的函數AM數組,而不是一組函數。 – SteAp 2012-02-25 14:28:37