|
Posted by Steve on 04/12/07 15:02
"Steve" <no.one@example.com> wrote in message
news:_HrTh.2221$Xq6.1291@newsfe12.lga...
|| consider this:
||
|| function level($n, $l = 0)
|| {
|| $ff = get_folders();
|| for ($i = 0; $i < count($ff); $i++)
|| {
|| if ($n != $ff[$i][0]){ continue; }
|| if ($ff[$i][4] != 0)
|| {
|| $l++;
|| level($ff[$i][4], $l);
|| } else {
|| return $l;
|| }
|| }
|| }
|
| lemme practice what i preach (and usually do)...
|
| function level($n, $l = 0)
| {
| $ff = get_folders();
| for ($i = 0; $i < count($ff); $i++)
| {
| if ($n != $ff[$i][0]){ continue; }
| if ($ff[$i][4] != 0)
| {
| level($ff[$i][4], ++$l);
| }
| return $l;
| }
| }
ooh, or how about this:
function level($n, $l = 0)
{
$ff = get_folders();
for ($i = 0; $i < count($ff); $i++)
{
if ($n != $ff[$i][0]){ continue; }
if ($ff[$i][4] == 0){ return $l; }
level($ff[$i][4], ++$l);
}
}
now there's even less to step in. ;^)
[Back to original message]
|