I get an undefined offset error only when I deal with files using the explode statement. It says the array created by the explode statement is undefined, but not when I deal with normal explode statements as per the code in the commented lines.
What is the explanation?
Extra information -- I have certainly used tab characters in the file:
<?php
$file = "../hai/jobs.txt";
if (file_exists($file))
{
$handle = fopen($file, "r");
if (!empty($file))
{
while (!feof($handle))
{
$curLine = fgets($handle);
if ($curLine != "")
{
$line = explode("\t", $curLine);
echo $line[1];
//$a = "hai,how,are,you,going";
//$array = explode (",", $a);
//echo $array[1];
}
}
}
fclose($handle);
}
?>
</body>
</html>