我的目标是将第一个索引(csv 中每一行的第一个值)放入下拉 htmlselect
列表中。
测试.csv
mark, blue, tall,
mike, black, short
索引.php
<?php
$handle = fopen("csv/food.csv", "r");
while (($data = fgetcsv($handle, 5000, ",")) !== FALSE) {
echo "<pre>";
print_r($data);
echo "<pre>";
}
?>
输出
Array
(
[0] => mark
[1] => blue
[2] => tall
[3] => mike
[4] => black
[5] => short
)
如果我在高后删除逗号,则输出
Array
(
[0] => mark
[1] => blue
[2] => tall
mike
[3] => black
[4] => short
)
期望的输出
Array
(
[0][0] => mark
[0][1] => blue
[0][2] => tall
[1][0] => mike
[1][1] => black
[1][2] => short
)