I there a php function that enables me to read a csv column (COLUMN NOT LINE) into an array or a string ?
thank you in advance.
Using array_map() to Read a CSV File Alternatively, you can use the array_map() function to read a CSV file into an array. To do this, you'll use str_getcsv as a callback function. This is a built-in PHP function that is used to parse a CSV string into an array.
PHP fgetcsv() Function$file = fopen("contacts. csv","r"); print_r(fgetcsv($file)); fclose($file);
$csv = array_map("str_getcsv", file("data.csv"));
$header = array_shift($csv);
// Seperate the header from data
$col = array_search("Value", $header, true);
foreach ($csv as $row) {
$array[] = $row[$col];
}
May this will help. http://www.php.net/manual/de/function.fgetcsv.php Just grab the position of the row for the column you want to have.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With