RE: [PHP] Re: recursive function not returning anything..

From: Date: Sun, 07 Nov 2004 19:07:17 +0000
Subject: RE: [PHP] Re: recursive function not returning anything..
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-201443@lists.php.net to get a copy of this message
Of course! Thank you. Nate -----Original Message----- From: M. Sokolewicz [mailto:tularis@php.net] Sent: Sunday, November 07, 2004 11:03 AM To: php-general@lists.php.net Subject: [PHP] Re: recursive function not returning anything.. nate@savingadvice.com wrote: > function recursePathLookup($CatID, $Path = array()) { > > //Get the catid for this subcat > > $sql = "SELECT SubCategoryID, Name FROM categories WHERE CategoryID = > '".$CatID."'"; > > $query = mysql_query($sql); > > if(mysql_num_rows($query) == 1) { > > $data = mysql_fetch_array($query); > > $Path[] = $data["Name"]; > > recursePathLookup($data["SubCategoryID"], $Path); change to: return recursePathLookup($data["SubCategoryID"], $Path); > > } else { > > //print_r($Path); > > return $Path; > > } > > } > > > > print_r(recursePathLookup(2)); > > > > Any ideas why when I uncomment the //print_r($Path) inside the function it > prints the value fine, but when I try to return the value and print it > outside the function I get nothing? > > Thanks, > > Nate > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#201443) next »