title: Save JSON output to a json file
body: <p>Got this code:</p>
  
  <pre><code>&lt;?php
    $jsonurl = "https://newsapi.org/v1/articles?source=cnn&amp;sortBy=top&amp;apiKey=d8dfc55aa005430c9567416cac34e3fa";
    $json = file_get_contents($jsonurl);
    var_dump(json_decode($json));
  
            $file = fopen('news.json','w');
            fwrite($file, $json);
            fclose($file);
  </code></pre>
  
  <p>But nothing gets saved to the new <code>news.json</code> file, why would this be? As I was taught - creating files is done using this method. (<code>w</code> on <code>fopen</code>)</p>