Search
 
SCRIPT & CODE EXAMPLE
 

PHP

read csv file in php

$row = 1;
if (($handle = fopen("test.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> $num fields in line $row: <br /></p>
";
        $row++;
        for ($c=0; $c < $num; $c++) {
            echo $data[$c] . "<br />
";
        }
    }
    fclose($handle);
}
Comment

php read csv

<?php
ini_set('auto_detect_line_endings',TRUE);
$handle = fopen('/path/to/file','r');
while ( ($data = fgetcsv($handle) ) !== FALSE ) {
  //process the array in $data
  var_dump($data);
}
ini_set('auto_detect_line_endings',FALSE);
Comment

get data from csv file in php and print in table

<!DOCTYPE html>
<html>
  
<body>
    <center>
        <h1>DISPLAY DATA PRESENT IN CSV</h1>
        <h3>Student data</h3>
  
        <?php
        echo "<html><body><center><table>

";
  
        // Open a file
        $file = fopen("a.csv", "r");
  
        // Fetching data from csv file row by row
        while (($data = fgetcsv($file)) !== false) {
  
            // HTML tag for placing in row format
            echo "<tr>";
            foreach ($data as $i) {
                echo "<td>" . htmlspecialchars($i) 
                    . "</td>";
            }
            echo "</tr> 
";
        }
  
        // Closing the file
        fclose($file);
  
        echo "
</table></center></body></html>";
        ?>
    </center>
</body>
  
</html>
Comment

PREVIOUS NEXT
Code Example
Php :: codeigniter input required function in php 
Php :: PHP setlocale — Set locale information 
Php :: php href variable in javascript alert 
Php :: propel find index 
Php :: PHP not echoing variables when print_r does 
Php :: drupal 9 custom local stream wrapper 
Php :: add column in exesting table 
Php :: zsh: command not found: php mac 
Php :: adding n days to a DATETIME format value 
Php :: add attachment to the invoice laravel 
Php :: Adding another return message from Laravel Livewire 
Php :: laravel not rollback even has error 
Php :: laravel get user aget from request 
Php :: To Search Specific Post Type 
Php :: laravel gigapay delete invoice 
Php :: How to Validate an Email Duplicate Entry in Codeigniter 
Php :: php split string in half 
Php :: laravel faker car plate br 
Php :: Best version control tools for php 
Php :: php exttends 
Php :: Laravel: Session message exist while click on browser back button 
Php :: php if simple 
Php :: php check if string startswith 
Php :: mkdir recursive php 
Php :: Replace default WP search and dropdown placeholder 
Php :: how to display all posts assocatied to user in laravel 
Php :: Submit and draft button use in laravel 
Php :: date fomat in php 
Php :: laravel sendgrid using 2 possible authenticators. Authenticator LOGIN returned Expected response code 250 
Php :: php browser detection script 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =