Skip to content

Instantly share code, notes, and snippets.

@nit3ch
Created January 24, 2014 10:29
Show Gist options
  • Save nit3ch/8595114 to your computer and use it in GitHub Desktop.
Save nit3ch/8595114 to your computer and use it in GitHub Desktop.
Script to convert csv file to php array
<?php
$one= array();
$handle = @fopen("file_name.csv", "r");
//$content = file_get_contents('hello.csv');
//print_r($content);
if ($handle) {
while (($row = fgetcsv($handle, 7000)) !== false){
//$key =array($row[0]);
//$value = array($row[1]);
$rowArray[$row[0]]= $row[1];
//$new = array_combine($key, $value);
//print_r($row);
}
print_r($rowArray);
if (!feof($handle)) {
echo "Error: unexpected fgets() fail\n";
}
fclose($handle);
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment