Search
 
SCRIPT & CODE EXAMPLE
 

PHP

laravel import data from csv

function csvToArray($filename = '', $delimiter = ',')
{
    if (!file_exists($filename) || !is_readable($filename))
        return false;

    $header = null;
    $data = array();
    if (($handle = fopen($filename, 'r')) !== false)
    {
        while (($row = fgetcsv($handle, 1000, $delimiter)) !== false)
        {
            if (!$header)
                $header = $row;
            else
                $data[] = array_combine($header, $row);
        }
        fclose($handle);
    }

    return $data;
}
Comment

how can we merge csv file in laravel

<?php
function joinFiles(array $files, $result) {
    if(!is_array($files)) {
        throw new Exception('`$files` must be an array');
    }

    $wH = fopen($result, "w+");

    foreach($files as $file) {
        $fh = fopen($file, "r");
        while(!feof($fh)) {
            fwrite($wH, fgets($fh));
        }
        fclose($fh);
        unset($fh);
        fwrite($wH, "
"); //usually last line doesn't have a newline
    }
    fclose($wH);
    unset($wH);
}
Comment

PREVIOUS NEXT
Code Example
Php :: function wp_maintenance_mode() { 763 
Php :: How to add logo in FPDF PHP 
Php :: create or update laravel 5.8 stackoverflow 
Php :: learnpress wordpress plugin shortcode 
Php :: powerpack add custom image size 
Php :: doiffernce between text and string in laravel migration 
Php :: Laravel You may use the sectionMissing directive to determine if a section does not have content: 
Php :: changing the autoload.php for algolia search 
Php :: stop php execution with javascript 
Php :: Multiple Formats with PHP DateTime::createFromFormat() 
Php :: php ?: 
Php :: php array push key value 
Php :: laravel get fetch api request body 
Php :: php associative array 
Php :: combine date time php 
Php :: laravel validation 
Php :: laravel get only validated data 
Php :: how to grab shortcode from custom post type 
Php :: wpdb count 
Php :: Append a text string to WooCommerce product title loop 
Java :: java get appdata path 
Java :: register listener spigot 
Java :: how to close a jframe in java with an if statement 
Java :: java pause 1 second 
Java :: java int to roman 
Java :: hello word java 
Java :: stringjoiner stream java 
Java :: jackson ignore null 
Java :: How to change progressbar color xml android 
Java :: foreground java jframe 
ADD CONTENT
Topic
Content
Source link
Name
5+8 =