Skip to content

Instantly share code, notes, and snippets.

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 collegeman/e243e774d70bb80f7b98 to your computer and use it in GitHub Desktop.
Save collegeman/e243e774d70bb80f7b98 to your computer and use it in GitHub Desktop.
<?php
// open the JSON file
$json = json_decode(file_get_contents('cleveland-film-festival-2016.json'));
// open a file to put the CSV into
$outfile = fopen('cleveland-film-festival-2016.csv', 'w');
// loop over the JSON file, one film at a time
foreach($json as $film) {
// build an array from the film content
$out = [
$film->title,
$film->url,
$film->email,
!empty($film->info[0]) ? $film->info[0] : null,
!empty($film->info[1]) ? $film->info[1] : null,
!empty($film->info[2]) ? $film->info[2] : null,
$film->website
];
// dump the array into our CSV file
fputcsv($outfile, $out);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment