title: PHP - Create a recursive json array parse in JQuery
body: <p>not sure if this can actually be done - OK probably can be done but beyond me.  I have a php recursive array function like this:</p>
  
  <pre><code>function recursive_array($results) {
  global $DBH;
  if(count($results)) { 
  echo $res-&gt;Fname;
  foreach($results as $res) {  
  $STH = $DBH-&gt;query("SELECT FID,FParentID,Fname FROM list WHERE FParentID  = " . $res-&gt;FID ."" );
  $fquerycount = $STH-&gt;rowCount();
  $STH-&gt;setFetchMode(PDO::FETCH_OBJ); 
   recursive_array($STH); 
  }}}
  </code></pre>
  
  <p>which starts on the page like this:</p>
  
  <pre><code>$FID = isset($_GET['FID']) ? $_GET[' FID'] : 0;
  $STH = $DBH-&gt;query("SELECT FID,FParentID,Fname FROM list WHERE FParentID ='0' " );
  $STH-&gt;setFetchMode(PDO::FETCH_OBJ);
  recursive_array($STH);
  </code></pre>
  
  <p>This function works well for me. BUT it is "plain" php.  what I would like to do is to create a json array rather than <code>echo</code> out the results.  Then to parse the results through JQuery.  My reason is I am using <code>$.getJSON('etc...')</code> for cross domain functionality with a "central" DB.  OK I can use Iframes and just create "template" pages at the "central" domain, but I would prefer not to. (I just hate frames/Iframes)</p>
  
  <p>Any suggestions / comments?</p>