note 117692 added to function.str-getcsv
| From: | starrychloe at oliveyou dot net | Date: | Thu, 23 Jul 2015 18:12:48 +0000 |
| Subject: | note 117692 added to function.str-getcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-203165@lists.php.net to get a copy of this message | ||
Based on James' line, this will create an array of associative arrays with the first row column
headers as the keys.
<?php
$csv = array_map('str_getcsv', file($file));
array_walk($csv, function(&$a) use ($csv) {
$a = array_combine($csv[0], $a);
});
array_shift($csv); # remove column header
?>
This will yield something like
[2] => Array
(
[Campaign ID] => 295095038
[Ad group ID] => 22460178158
[Keyword ID] => 3993587178
----
Server IP: 72.52.91.14
Probable Submitter: 208.120.122.29
----
Manual Page -- http://php.net/manual/en/function.str-getcsv.php
Edit -- https://master.php.net/note/edit/117692
Del: integrated -- https://master.php.net/note/delete/117692/integrated
Del: useless -- https://master.php.net/note/delete/117692/useless
Del: bad code -- https://master.php.net/note/delete/117692/bad+code
Del: spam -- https://master.php.net/note/delete/117692/spam
Del: non-english -- https://master.php.net/note/delete/117692/non-english
Del: in docs -- https://master.php.net/note/delete/117692/in+docs
Del: other reasons-- https://master.php.net/note/delete/117692
Reject -- https://master.php.net/note/reject/117692
Search -- https://master.php.net/manage/user-notes.php