Skip to content

Instantly share code, notes, and snippets.

@kajigga
Created February 11, 2013 20:05
Show Gist options
  • Save kajigga/4757161 to your computer and use it in GitHub Desktop.
Save kajigga/4757161 to your computer and use it in GitHub Desktop.
<?php
// Read the php input and save it to a file.
$fname = sprintf('takegrades_output/output_%s.txt',uniqid());
print $fname;
file_put_contents($fname,file_get_contents('php://input'));
/*
* Read the input sent via the script, parse it as CSV and save it in
* $grade_data_received which is an associative array
*/
$grade_data_received = array();
if (($handle = fopen($fname, "r")) !== FALSE) {
$header_keys = array();
$header_keys = fgetcsv($handle,0,",");
while (($data = fgetcsv($handle, 0, ",")) !== FALSE) {
$grade_data_received[] = array_combine($header_keys,array_pad($data,count($header_keys),"-"));
}
}
print_r($grade_data_received);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment