Created
March 18, 2016 14:53
-
-
Save collegeman/e243e774d70bb80f7b98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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