Skip to content

Instantly share code, notes, and snippets.

@ababkov
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ababkov/e5d43526191fd79119ee to your computer and use it in GitHub Desktop.
Save ababkov/e5d43526191fd79119ee to your computer and use it in GitHub Desktop.
Convert JSON file to CSV
<?php
$json = json_decode(file_get_contents("source.json"),true);
$fh = fopen("target.csv","w+");
fputcsv($fh,array_keys(current($json)));
foreach($json as $row){
fputcsv($fh,$row);
}
fclose($fh);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment