PHP - Accessing CSV file and printing specific cells on the screen

2

How to access a .CSV file via PHP and print a specific cell on the screen ?!
Example:

Column A - Line 1
It is written: Alexandre

How to get this cell from "A1" and print on the screen?!
I want to apply this in this DASHBOARD:

Example:

In the CSV there is "Planned: 5,000" , I want to get that cell that says the planned day is 5,000 and put it there on the dashboard, where "null" strong>.

    
asked by anonymous 11.08.2017 / 14:38

1 answer

1

Hello,

The function that will help you in this case is fgetcsv.

Official documentation: link

Example extracted from official documentation:

<?php
$row = 1;
if (($handle = fopen("teste.csv", "r")) !== FALSE) {
    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
        $num = count($data);
        echo "<p> $num campos na linha $row: <br /></p>\n";
        $row++;
        for ($c=0; $c < $num; $c++) {
            echo $data[$c] . "<br />\n";
        }
    }
    fclose($handle);
}
?>
    
15.08.2017 / 19:19