title: Recursive PHP function not returning result
body: <p>Just a simple function to build breadcrumbs based off a simple database table where there are columns:</p>
  
  <pre><code>id, parent, title
  </code></pre>
  
  <p>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:</p>
  
  <pre><code>    function getCategoryParents($id=0, $out=array()) {
          $id = (int)$id;
          if ($id &gt; 0) {
              $query = "SELECT * FROM `" .$this-&gt;tables['categories']. "` WHERE (`id`=" .$id. ")";
              $cat = sqlfetch(sqlquery($query));
              array_push($out, $cat);
              if ($cat['parent']) {
                  $this-&gt;getCategoryParents($cat['parent'], $out);
              } else {
                  return $out;
              }
          } else {
              return $out;
          }
      }
  </code></pre>
  
  <p>But it's not returning anything. But, if I do a print_r($out) from within the function instead of return, ex:</p>
  
  <pre><code>            if ($cat['parent']) {
                  $this-&gt;getCategoryParents($cat['parent'], $out);
              } else {
                  echo print_r($out);
              }
  </code></pre>
  
  <p>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!</p>
  
  <p>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).</p>