【发布时间】:2013-06-13 11:36:28
【问题描述】:
该文件包含 3 列(制表符分隔)和 10 行。如何从数组 $lines 中获取 [column][row]?目前该数组包含 10 行。
$handle = @fopen('results.txt', "r");
if ($handle) {
while (!feof($handle)) {
$lines[] = fgets($handle, 4096);
}
fclose($handle);
}
for($i=0; $i<count($lines); $i++)
{
echo $lines[$i];
}
【问题讨论】:
-
你可以使用 explode("\t") 来获取列。
-
看看使用PHP内置的fgetcsv()函数而不是fgets()
-
@Cobra_Fast outch,需要睡觉 ;) 谢谢!