Php code problem newb needs help?

  • Thread starter Thread starter bmisericorde
  • Start date Start date
B

bmisericorde

Guest
Here is what my code looks like:

<?php
$filename='inventory.txt';
$fp = fopen($filename, 'r');
if ($fp) {
$array = explode("\n", fread($fp, filesize($filename)));
}

$numlines=count($array);

for ($i=0;$i<$numlines;$i++){
print $array;
}

?>

For some reason, I get the output ArrayArrayArrayArray

i want the file read and output line by line, using only the newline as a seperator
tried
print $array(i);

said "function name must be a string."
okay, my c++ talking, used
$array;
no output at all.
Okay, was using i instead of $i, thank you.
 
You will find the array prints better like this:
print $array[$i];

You might also want to look at "file":
http://www.php.net/manual/en/function.file.php
 
Back
Top