Answers for "csv import php"

PHP
2

php open csv

$csvFile = file('../somefile.csv');
    $data = [];
    foreach ($csvFile as $line) {
        $data[] = str_getcsv($line);
    }
Posted by: Guest on September-02-2020
0

import data from csv to db php

<?php
$query = <<<eof
    LOAD DATA INFILE '$fileName'
     INTO TABLE tableName
     FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
     LINES TERMINATED BY '\n'
     IGNORE 1 LINES
    (field1,field2,field3,etc)
eof;

$db->query($query);
?>
Posted by: Guest on November-12-2020

Browse Popular Code Answers by Language