为什么只执行了 $y=0 呢, $y=1,$y=2,跳过去了。function count_this_bl($uid,$k,$rand_num)
{
global $_SGLOBAL;
static $rand=0;
static $num3;
if($rand != $rand_num)
{
$num3=0;
$rand = $rand_num;
}
static $i = 0;
for($i=$k;$i>0;$i--) // $k 层次
{
$result = $_SGLOBAL['db']->fetch_one('select level1,level2,level3 from uc_level where uid='.$uid);
if($result)
{
for($y=0;$y<3;$y++) //判断 L1,L2,L3 是否为空
{
if($result[$y]) //继续 L -> $y 下层
{
$num3++;
echo $num3.'呵呵<br />';
count_this_bl($result[$y],$i,$rand);
}
}
} }
return $num3;
}
{
global $_SGLOBAL;
static $rand=0;
static $num3;
if($rand != $rand_num)
{
$num3=0;
$rand = $rand_num;
}
static $i = 0;
for($i=$k;$i>0;$i--) // $k 层次
{
$result = $_SGLOBAL['db']->fetch_one('select level1,level2,level3 from uc_level where uid='.$uid);
if($result)
{
for($y=0;$y<3;$y++) //判断 L1,L2,L3 是否为空
{
if($result[$y]) //继续 L -> $y 下层
{
$num3++;
echo $num3.'呵呵<br />';
count_this_bl($result[$y],$i,$rand);
}
}
} }
return $num3;
}
的到得是什么?输出一个看看
0=>1111,
level1=>1111,
1=>2222,
level2=>2222,
2=>3333,
level3=>3333
);最开始时,它执行了 array[0] ,然后就开始递归了,但是没有返回 array[1]和 array[2]再次递归。
注释掉就应该可以了