Search
 
SCRIPT & CODE EXAMPLE
 

PHP

Csv To AssoT Php

<?php
    //Map lines of the string returned by file function to $rows array.
    $rows   = array_map(function($employee){return explode(",",$employee); }, file('employees.csv'));
    //Get the first row that is the HEADER row.
    $header_row = array_shift($rows);
    //This array holds the final response.
    $employee_csv    = array();
 
    foreach($rows as $row) {
        if(!empty($row)){
            $temp = [];
            //Loop through the individual attributes in the row and map it to a corresponding header.
            for($i =0; $i < count($row); $i++)
            {
                $temp[$header_row[$i]] = $row[$i];
            }
 
            //Push the row to the employees array.
            array_push($employee_csv,$temp);
            
        }
    }
 
    print_r($employee_csv)
?>
Comment

PREVIOUS NEXT
Code Example
Php :: laravel hiding attributes JSON 
Php :: php unique id length 
Php :: Update Data Multiple Columns MySql Database Table PHP Function 
Php :: session in laravel 
Php :: tenary php 
Php :: send image in request body laravel 6 
Php :: php xpath attribute exact 
Php :: laravel php what does compact 
Php :: manual collection laravel 
Php :: routing with php 
Php :: the plugin generated 14 characters of unexpected output during activation. if you notice “headers already sent” messages, problems with syndication feeds or other issues, try deactivating or removing this plugin 
Php :: array_filter in php 
Php :: php access class variable 
Php :: delete record without a page refresh with ajax in php 
Php :: php object to json 
Php :: laravel print builder 
Php :: laravel eloquent join two models 
Php :: php array_pop with key 
Php :: restart php service windows 
Php :: laravel where in query builder 
Php :: email verification laravel 
Php :: $session php 
Php :: query builder codeigniter 
Php :: https://ubuntu.com/tutorials/install-and-configure-wordpress#3-install-wordpress 
Php :: drop column laravel migration 
Php :: php integer variable 
Php :: send data to api php 
Php :: WooCommerce shop loop random array function not same values after each other 
Php :: PHP Warning: Module "curl" is already loaded in Unknown on line 0 
Php :: menyimpan get di laravel 
ADD CONTENT
Topic
Content
Source link
Name
3+5 =