Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

csv file to associative array php

<?php
    /* Map Rows and Loop Through Them */
    $rows   = array_map('str_getcsv', file('file.csv'));
    $header = array_shift($rows);
    $csv    = array();
    foreach($rows as $row) {
        $csv[] = array_combine($header, $row);
    }
?>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #csv #file #associative #array #php
ADD COMMENT
Topic
Name
1+8 =