Re: recursive function not returning anything..
| From: | M. Sokolewicz | Date: | Sun, 07 Nov 2004 19:02:53 +0000 |
| Subject: | Re: recursive function not returning anything.. | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-201440@lists.php.net to get a copy of this message | ||
nate@savingadvice.com wrote:
function recursePathLookup($CatID, $Path = array()) {return recursePathLookup($data["SubCategoryID"], $Path);//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:
} 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