Getting error Undefined offset: 1
I know that this error has occurred a lot, however I have not been able to
find another question on the site that lines up my my issue.
Here is my code:
<?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];
?>
I keep getting the error "Notice: Undefined offset: 1 in
C:\wamp\www\arraytest.php on line 20"
although I get the error I printed out the first two values from the array
and they both seem to be correct, so I don't know exactly what is causing
this.
--EDIT--
Here is the structure of my data I am importing:
12,13
12,14
12,15
12,16
12,17
12,18
12,21
12,22
12,31
No comments:
Post a Comment