Re: recursion

From: Date: Tue, 30 Jan 2001 09:24:22 +0000
Subject: Re: recursion
Groups: php.db 
Request: Send a blank email to php-db+get-6256@lists.php.net to get a copy of this message
Addressed to: "Andrew" <kozak@ps.kiev.ua> php-db@lists.php.net ** Reply to note from "Andrew" <kozak@ps.kiev.ua> Tue, 30 Jan 2001 10:17:40 +0200 > > Hi, Does PHP4 support recursive function ivocation? It seemed tome > that it does not, because the code below doesn't work properly. Yes, PHP does support recursion. I don't understand what you are trying to do. How about including an example of what comes in $arr when the function is called, what $this->$deptree has to do with anything and what you want the output to look like. I'm not big on OOP, but $this->$deptree does not look right. Also usually when I see a recursive function the values passed to the function when it calls itself are derived from the values passed when it was first called. > function RecPrintDeps($arr, $depth=0){ > //print_r($arr); > $depth++; > printf("<H$depth><a > href=\"%s?dep=%s\">%s</a></H$depth>", $HTTP_SELF, $arr[0], $arr[2]); > while(list($k,$v)=each($this->$deptree)){ > if($v[1]==$arr[0]) > $this->RecPrintDeps($v,$depth); > } > } Rick Widmer Internet Marketing Specialists http://www.developersdesk.com

« previous php.db (#6256) next »