[newbie] minor trouble with "while, list and explode" from a text-file
| From: | SED | Date: | Wed, 07 Feb 2001 03:44:19 +0000 |
| Subject: | [newbie] minor trouble with "while, list and explode" from a text-file | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-38480@lists.php.net to get a copy of this message | ||
Hi, I'm trying to figure out how to do this right:
I have this text file:
date 1 | head 1 | text 1
date 2 | head 2 | text 2
date 3 | head 3 | text 3
And I want to display in a HTML-page like this:
date 1
head 1
text 1
date 2
head 2
text 2
date 3
head 3
text 3
And I'm trying to do it with follwing code:
//sniped
39> while (list ($line_num, $line) = each ($contentlines))
40> {
41> $message = explode ("|", $line);
42>
43> while (list ($date, $head, $text) = each($message))
44> {
45> echo "$date, $head, $text<br>";
46> };
47> };
//sniped
But I get this result:
Warning: Undefined offset: 2 in c:\inetpub\wwwroot\read_txt_0007.php on
line 43
0, date 1,
Warning: Undefined offset: 2 in c:\inetpub\wwwroot\read_txt_0007.php on
line 43
1, head 1,
Warning: Undefined offset: 2 in c:\inetpub\wwwroot\read_txt_0007.php on
line 43
2, text 1,
Warning: Undefined offset: 2 in c:\inetpub\wwwroot\read_txt_0007.php on
line 43
0, date 2,
etc.
Can anyone point me to a solution for this?
Regards,
Sumarlidi Einar Dadason
SED - Graphic Design
------------------------------------------
Phone: (+354) 4615501
Mobile: (+354) 8960376
Fax: (+354) 4615503
E-mail: sed@sed.is
Homepage: www.sed.is <- New Homepage!
------------------------------------------