RE: [PHP] HELP! printing Arrays
| From: | Chris W. Parker | Date: | Wed, 03 Mar 2004 23:43:29 +0000 |
| Subject: | RE: [PHP] HELP! printing Arrays | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-179387@lists.php.net to get a copy of this message | ||
Labunski <mailto:labunski@latnet.lv>
on Wednesday, March 03, 2004 3:31 PM said:
> Hello,
>
> // This will print first and sixth line from the text file:
> $file = file("people.txt");
> print "$file[0]<br>";
> print "$file[6]<br>";
actually that will print the first and seventh line of the file...
> // But how to print all the lines from [0] to [6] ?
> // Hope you understood my problem.
// to print ALL lines
foreach($file as $key => $value)
{
echo "$key: $value<br>";
}
// to print lines 1-7
for($ictr = 0; $ictr < 6; $ictr++)
{
echo "{$file[$ictr]}<br>";
}
> sorry for my bad english,
> Lab.
no problem.
hth,
chris.