Reply to Re: problem returning value using recursive function

Your name:

Reply:


Posted by Vince Morgan on 04/12/07 12:57

"Rienk Withaar" <r.g.withaar@rug.nl> wrote in message
news:evl3vj$abq$2@info.service.rug.nl...
> Hello, I have the following problem:
>
> I want my function to return a value, $l, using the following function:
>
> function level($n,$l=0,$d=false) {
> if ($d) { return $l; }
> else {
> $ff=get_folders();
> for ($i=0;$i<count($ff);$i++) {
> if ($n==$ff[$i][0]) {
> if ($ff[$i][4]!=0) {

Post-incrementing here will cause$1 to be incremented by 2 on the next
recursion.
If on the first pass $1 = 0, on the second pass it will be 2, not 1.
If that is your goal, I've not found a problem ;)

> $l++;

> level($ff[$i][4],$l,$d);
> }
> else {
> $d=true;
> level($ff[$i][0],$l,$d);
> }
> }
> }
> }
> }
>
HTH
Vince

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация