读取CSV到Array的特定列(Read specific column in CSV to Array)
我试图读取我的csv文件中的某些数据并将其传输到数组。 我想要的是获取某一列的所有数据,但我想从某一行开始(比方说,例如,第5行),有可能这样做吗? 我现在只获取特定列中的所有数据,想要在第5行启动它,但无法想到任何方法。 希望你们能帮助我。 谢谢!
<?php //this is column C $col = 2; // open file $file = fopen("example.csv","r"); while(! feof($file)) { echo fgetcsv($file)[$col]; } // close connection fclose($file); ?>
I am trying to read a certain data in my csv file and transfer it to an array. What I want is to get all the data of a certain column but I want to start on a certain row (let say for example, row 5), is there a possible way to do it? What I have now only gets all the data in a specific column, want to start it in row 5 but can't think any way to do it. Hope you guys can help me out. Thanks!
<?php //this is column C $col = 2; // open file $file = fopen("example.csv","r"); while(! feof($file)) { echo fgetcsv($file)[$col]; } // close connection fclose($file); ?>
原文:https://stackoverflow.com/questions/35740176
更新时间:2022-04-13 09:04
最满意答案
<table border='1'> <tr> <th>Beat:</th> <? $times = rand(1,12); $i = 1; while ($i <= $times) { echo "<th>$i</th>"; $i++; } ?> </tr> <tr> <td>Accent:</td> <td>X</td> <? $i = 1; while ($i <= ($times-1)) { if (rand(0,1)) { echo "<td>x</td>";} else {echo "<td>-</td>";} $i++; } ?> </tr> </table>
<table border='1'> <tr> <th>Beat:</th> <? $times = rand(1,12); $i = 1; while ($i <= $times) { echo "<th>$i</th>"; $i++; } ?> </tr> <tr> <td>Accent:</td> <td>X</td> <? $i = 1; while ($i <= ($times-1)) { if (rand(0,1)) { echo "<td>x</td>";} else {echo "<td>-</td>";} $i++; } ?> </tr> </table>
相关问答
更多-
TCP/IP模型是一个________。[2023-10-02]
a -
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -