title: How can i access json array in php and save it in .json file
body: <p><strong>Current PHP Code is working but I need to save JSON as I mentioned in the example</strong> 
  I need to access all data of array and save it inside the <strong>.JSON</strong> File</p>
  
  <pre><code>&lt;?php
      $curl = curl_init();
      $fh = fopen('local.json','w');
      curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
      curl_setopt($curl, CURLOPT_URL, "https://jsonstorage.net/api/items/46b5a62d-9a39-41ab-89f4-e75f458c9189");
      curl_setopt($curl, CURLOPT_FILE, $fh);
      curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
      $contents = curl_exec($curl);
      fwrite($fh, $contents);
      curl_close($curl);
      fclose($fh);
  ?&gt;
  </code></pre>
  
  <p><strong>My JSON data is in this form but I need to access all data of [data]</strong></p>
  
  <pre><code>{
    "data": [
      {
        "adapterid": 44835,
        "rowid": 1573784208932,
        "battery": 3610,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -90,
        "temp": 25.75
      },
      {
        "adapterid": 44835,
        "rowid": 1573784212032,
        "battery": 3660,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -89,
        "temp": 25.75
      },
      {
        "adapterid": 44835,
        "rowid": 1573784215034,
        "battery": 3610,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -96,
        "temp": 25.75
      }
  ]
  }
  </code></pre>
  
  <p><strong>the response I want is:</strong>  </p>
  
  <pre><code>{
    "data": [
                **I want this data** 
            ]
  }
  </code></pre>
  
  <p>here is the example sample of my requirement:</p>
  
  <pre><code>[
      {
        "adapterid": 44835,
        "rowid": 1573784208932,
        "battery": 3610,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -90,
        "temp": 25.75
      },
      {
        "adapterid": 44835,
        "rowid": 1573784212032,
        "battery": 3660,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -89,
        "temp": 25.75
      },
      {
        "adapterid": 44835,
        "rowid": 1573784215034,
        "battery": 3610,
        "createddate": "15-11-2019",
        "gid": "01:f0:50:11:a1:35:87",
        "id": 2277491836402479600,
        "projectid": 32107,
        "rssi": -96,
        "temp": 25.75
      }
  ]
  </code></pre>
  
  <p>How can I access this?
  Thanks in advance</p>