Array ( [0] => Array ( [0] => Hotel [1] => 20 ) [1] => Array ( [0] => Hotel [1] => 210 ) [2] => Array ( [0] => Food [1] => 29.04 ) [3] => Array ( [0] => Fuel [1] => 186 ) [4] => Array ( [0] => Food [1] => 55 ) )
<pre><!DOCTYPE html> <html> <body> <center> <h1>DISPLAY DATA PRESENT IN CSV</h1> <h3>CSV File</h3> <?php // include 'file.php'; echo "<html><body><center><table>\n\n"; // $fileName = $_POST['csvfile']; $fileName = "./test.csv"; $summary = array(); $i = 0; $sum; $index = null; $file = fopen($fileName, "r"); while($data = fgetcsv($file)){ if($index !== $data[2]){ $summary[$i] = array($data[0], $data[1] * $data[2]); if($i > 0){ $summary[$i][0] = $data[0]; } $index = $data[1]; ++$i; echo "<tr>"; } } // // fclose($file); print_r($summary); // print_r($res); // function csvToArray($csvFile){ // $file_to_read = fopen($csvFile, 'r'); // while (!feof($file_to_read) ) { // $lines[] = fgetcsv($file_to_read, 1024); // } // fclose($file_to_read); // return $lines; // } // $csvFile = 'test.csv'; // $csv = csvToArray($csvFile); // echo '<pre>'; // print_r($csv); // echo '
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)