递归PHP函数不返回结果

Just a simple function to build breadcrumbs based off a simple database table where there are columns:

id, parent, title

The "parent" column can be 0 for top-level, or the "id" of another row for sub-categories (unlimited depth). All I'm trying to do is have a function that'll help me build breadcrumbs from it, starting from the "id" of the bottom-most category I specify and working its way up to the top parent. Here's what I have:

    function getCategoryParents($id=0, $out=array()) {
        $id = (int)$id;
        if ($id > 0) {
            $query = "SELECT * FROM `" .$this->tables['categories']. "` WHERE (`id`=" .$id. ")";
            $cat = sqlfetch(sqlquery($query));
            array_push($out, $cat);
            if ($cat['parent']) {
                $this->getCategoryParents($cat['parent'], $out);
            } else {
                return $out;
            }
        } else {
            return $out;
        }
    }

But it's not returning anything. But, if I do a print_r($out) from within the function instead of return, ex:

            if ($cat['parent']) {
                $this->getCategoryParents($cat['parent'], $out);
            } else {
                echo print_r($out);
            }

It outputs the array just fine. But I need to be able to actually work with the array, so I need it returned from the function. I'm sure I'm missing something incredibly small, but I cannot figure it out for the life of me!

Also, I don't want to do a global variable, and also need the info of the category id specified in the initial function call as part of the array as well (as I was trying to do).

Following the suggestions, here's what ended up working:

    function getCategoryParents($id=0) {
        $out = array();
        $id = (int)$id;
        if ($id > 0) {
            $query = "SELECT * FROM `" .$this->tables['categories']. "` WHERE (`id`=" .$id. ")";
            $cat = sqlfetch(sqlquery($query));
            array_push($out, $cat);
            if ($cat['parent']) {
                $out = array_merge($out, $this->getCategoryParents($cat['parent']));
            }
        }
        return $out;
    }