Jump to content


Need help with delimit a text file to a table

  • Please log in to reply
2 replies to this topic

#1 olebrum

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 August 2006 - 03:53 PM

Hi, this is my first post (just wanted you to know)!

I have a "small" problem. I got a text file with results that i want to delimit and put into a table. The text generated to a file is:

in a text file called, liste.txt, it will be like this:
Ole Lasse Johansen|10|10-08-2006 13:54:40

I want this text to be in a table:

NavnPoeng (x av 10)Dato
Ole Lasse Johansen1010-08-2006 13:54:40

I wrote this script, but can't get it to work, how can i get it to work??

  <TITLE>Spill: Desimal, Binær og Heksadesimal tall</TITLE>

<FONT SIZE="4">Spill: Desimal, Binær og Heksadesimal tall</FONT><BR><BR>


$liste = "./liste.txt";
if(!($fp = fopen($liste, "r"))) die ("Kan ikke åpne $liste.");
$innhold = fread($fp);

$delimiter = "|";
$splitinnhold = explode($delimiter, $innhold);
$teller = "";


    <TD>Poeng (x av 10)</TD>


foreach ($splitinnhold as $text)

  echo "  <TR>\n";
  while($kolonne < $kolonner)
    echo $text;
  echo "  </TR>\n";




#2 king arthur

king arthur
  • Members
  • PipPipPip
  • Advanced Member
  • 335 posts
  • LocationUK HQ

Posted 10 August 2006 - 04:03 PM

You've forgotten the table cell tags in your while loop.
while($kolonne < $kolonner)
    echo "<td>" . $text . "</td>";

Sir Isaac Newton said "If I have seen farther, it is by standing on the shoulders of giants". But it is not recorded as to whether he said it before or after he was hit on the head by a falling apple.

#3 olebrum

  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 10 August 2006 - 04:08 PM

yes that's true, but it still doesn't work... I'll attach both liste.txt and liste.php so you can try for yourself.. I just can't figure it out...

[attachment deleted by admin]

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users