我知道这个错误已经发生了很多,但是我无法在网站上找到另一个与我的问题相符的问题。
这是我的代码:
<?php
$handle = fopen('text document here', 'r');
if ($handle === false) {
die("ERROR");
}
$array = array();
$array = fgets($handle);
$handle = explode("\n", $array);
$foo = $handle;
$outA = array();
$outB = array();
foreach($foo as $value)
{
list($x, $y) = explode(",",$value);
$outA[] = $x;
$outB[] = $y;
}
echo $outA[0];
echo $outB[0];
?>
我不断收到错误“注意:未定义的偏移量:第 20 行 C:\wamp\www\arraytest.php 中的 1”
虽然我得到了错误,但我从数组中打印了前两个值,它们似乎都是正确的,所以我不知道究竟是什么原因造成的。
- 编辑 -
这是我要导入的数据的结构:
12,13
12,14
12,15
12,16
12,17
12,18
12,21
12,22
12,31