Created
May 17, 2019 14:42
-
-
Save SebbeJohansson/8f5071c3b7689d6414f854a366bc26fc to your computer and use it in GitHub Desktop.
This file contains 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
$row = 1; | |
$keys = []; | |
$array = []; | |
if (($handle = fopen("themes/fritidsfabriken/docs/feature_value_export_CZ_en.csv", "r")) !== FALSE) { | |
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { | |
$num = count($data); | |
//echo "<p> $num fields in line $row: <br /></p>\n"; | |
$value = []; | |
for ($c=0; $c < $num; $c++) { | |
//echo $data[$c] . "<br />\n"; | |
if($row == 1){ | |
$keys[] = $data[$c]; | |
}else{ | |
$value[$keys[$c]] = trim($data[$c]); | |
} | |
} | |
//var_dump($value); | |
if($row != 1){ | |
$array[] = $value; | |
} | |
$row++; | |
} | |
fclose($handle); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment