title: Generate .json file with PHP MySQL
body: <p>I'm trying to generate a json file with PHP with the code below and I'm getting an empty array -> {"posts":[]}. I'm using Wordpress. Can someone assist me. Thanks</p>
  
  <pre><code>    $sql=mysql_query("SELECT * FROM wp_posts"); 
  
      $response = array();
      $posts = array();
      $result=mysql_query($sql);
      while($row=mysql_fetch_array($result)) 
      { 
      $url['url']=$row; 
      $title['title']=$row;
  
      $posts[] = array('url'=&gt; $url, 'title'=&gt; $title);
  
      } 
  
      $response['posts'] = $posts;
  
      $fp = fopen('results.json', 'w');
      fwrite($fp, json_encode($response));
      fclose($fp);
  </code></pre>