note 84388 added to function.fgetcsv
| From: | VijayarajNagarajan at osu1 dot php dot net | Date: | Fri, 11 Jul 2008 15:40:35 +0000 |
| Subject: | note 84388 added to function.fgetcsv | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-141406@lists.php.net to get a copy of this message | ||
I used this simple php code for reading a csv file with two columns (without column heads) and
generating an associative array out of it...
<?php
#reads the file data.csv
$data=file("data.csv", FILE_IGNORE_NEW_LINES);
#explodes each line contents and assigns the values to an array
foreach ($data as $line)
{
$mparts=explode(',',$line);
#pushes the array values in to an associative array
$dataarray[$mparts[0]]=$mparts[1];
}
#prints the values of the new associative array
print_r($dataarray);
?>
----
Server IP: 209.41.74.194
Probable Submitter: 131.95.54.222
----
Manual Page -- http://www.php.net/manual/en/function.fgetcsv.php
Edit -- https://master.php.net/note/edit/84388
Del: integrated -- https://master.php.net/note/delete/84388/integrated
Del: useless -- https://master.php.net/note/delete/84388/useless
Del: bad code -- https://master.php.net/note/delete/84388/bad+code
Del: spam -- https://master.php.net/note/delete/84388/spam
Del: non-english -- https://master.php.net/note/delete/84388/non-english
Del: in docs -- https://master.php.net/note/delete/84388/in+docs
Del: other reasons-- https://master.php.net/note/delete/84388
Reject -- https://master.php.net/note/reject/84388
Search -- https://master.php.net/manage/user-notes.php