Search
 
SCRIPT & CODE EXAMPLE
 

PHP

how to fetch associate data from csv in php

function csvToArray($path)
{
    try{
        $csv = fopen($path, 'r');
        $rows = [];
        $header = [];
        $index = 0;
        while (($line = fgetcsv($csv)) !== FALSE) {
            if ($index == 0) {
                $header = $line;
                $index = 1;
            } else {
                $row = [];
                for ($i = 0; $i < count($header); $i++) {
                    $row[$header[$i]] = $line[$i];
                }
                array_push($rows, $row);
            }
        }
        return $rows;
    }catch (Exception $exception){
        return false;
    }
}
Comment

PREVIOUS NEXT
Code Example
Php :: php print fetch 
Php :: get object value by key php 
Php :: @yield laravel 
Php :: $$ in php 
Php :: envoyer des donnees js a php 
Php :: How do I ge the version of wordpress? 
Php :: return pdft download and back with msg in laravel 
Php :: change apply coupon text woocommerce 
Php :: laravel make api resource 
Php :: while in php 
Php :: causes of class not found in laravel 
Php :: php unique id length 
Php :: tenary php 
Php :: update to php 7.4 
Php :: wordpress if page 
Php :: @yield extends laravel 
Php :: php fetch return false 
Php :: how to create route in laravel 
Php :: laravel 8 php version requirements 
Php :: Laravel 7 pagination with search filter 
Php :: laravel eloquent join two models 
Php :: php in html need .htaccess 
Php :: compare key and one array 
Php :: php array_diff_assoc 
Php :: laravel image max size validation 
Php :: php form validation 
Php :: define multiple variables in one line php 
Php :: php qrcode 
Php :: laravel request query logger 
Php :: PHP Filters Advanced 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =