multidimensional array - How do I retrieve data csv just a few lines with php -


i have csv file results of scanning. want read first column , read lines , including line 6.

this have tried:

<html> <body> <h1>mac address have been verified</h1>  <table width="50%" border="1"> <tr>     <th>no</th>     <th>mac address</th> </tr>  <?php if (($handle = fopen("data.csv", "r")) !== false) {     $row = 1;     while (($data = fgetcsv($handle, 1000, ",")) !== false) {         echo "<tr>";         echo "<td><center>".$row++."</center></td>";         echo "<td>".$data[0]."</td>";         echo "</tr>";     } //end while     fclose($handle); } //end if  ?> </table> </body>enter code here </html> 

the important line below if ( $row > 6 ) break;

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

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

node.js - How to abort query on demand using Neo4j drivers -