I am attemping to read a flat file line. then explode it.
I am having a bit of troubles with this. the sample text file is as follows:
555551819|apple|19840101|
555551843|orange|19830101|
555552080|cherry|19840101|
555552148|bannana|19840101|
555552197|peach|19840101|
555552221|grape|19840101|
555552296|kiwi|19820101|
seperated by pipes.
//var definition
$row_number = \"6\"
$filename = \'data\\data_sort.txt\';
//open, read line
$fg = fopen ($filename,\"r\");
$row_contents = fgets($fg, $row_number);
//explode
list($NUMBER, $FRUIT, $DO😎 = explode(\"|\", $row_contents);
//close, and return value
fclose($fg);
return \"$NUMBER\";
what am i missing? (obviously i am pretty new to PHP, but i have a feeling it is a pretty easy solution, but searching the net and my PHP books for fgets examples all yeild the same example (which doesnt help):
$fd = fopen (\"/tmp/inputfile.txt\", \"r\");
while (!feof ($fd)) {
$buffer = fgets($fd, 4096);
echo $buffer;
}
fclose ($fd);