So, I have a CSV file that looks like this:
12345, Here is some text
20394, Here is some more text
How to insert this into an array that looks like this
$text = "12345" => "Here is some text",
"20394" => "Here is some more text";
This is what I currently had to get based on a numeric value for CSV level 1
if ($handle = fopen("$qid", "r")) {
$csvData = file_get_contents($qid);
$csvDelim = "\r";
$qid = array();
$qid = str_getcsv($csvData, $csvDelim);
} else {
die("Could not open CSV file.");
}
Thanks for the answers, but I still see a potential problem. With these solutions, values ββare not saved in this way:
$array[0] = 12345
$array[1] = Here is some text 20394
$array[2] = Here is some more text
If I tried this with the csv example above, how would the array be structured?
source
share