Jump to content

how do i display a text file as an array?


LuckY07

Recommended Posts

I have a text file called 'input.txt' that I want to put into an array and display each row. The setup I have now is only

displaying the first letter from each row for some reason.. here is my code: (i want to print the entire row, not just the 1st letter)

$array = file("input.txt");
foreach($array as $row) {
$i = 0;
print "$row[i]";
print "<br/>";
$i++;
}

 

Link to comment
Share on other sites

thanks! that worked.

 

i wonder why that only showed 1 letter before.. maybe because i was using print with double quotes?

 

i am going to be using this text file eventually for a 'user comments' box on my website. is displaying dynamic

html from a text file for user comments practical?

Link to comment
Share on other sites

interesting. so if i wanted to just print for example, row 2, how would i do that? i guess i dont know how to move the curser to the 2nd line.

 

basically i have an html page.. and i want to print these names and emails, along with a comment box eventually. I want to post the comments under the right date of a simple 1 page blog. for example)

 

here is how i want the page to look:

 

Blog Entry #1

<names for each comment>

<comments from that date>

 

Blog Entry #2

<names for each comment>

<comments from that date>

 

what would be the best way to do this? should i create a new text file for each date? or store all the comments/names/email in 1 text?

any help is appreciated. i am basically trying to add a 'comment box' to a simple website. tks.

Link to comment
Share on other sites

Thanks.

 

Do you think that I should be using MySQL for this? Basically I want to create a simple website with blog entries on the main page.

When you click the blog entry it takes you to another page where it displays the entry, and then a form where users can comment.

I then want to display just the name/email/comments that user leave on that page, like the following:

----------------------------------------------------------------------------------------------------

Blog Entry:

<user name/email>

<comments>

 

<user name2/email>

<comments>

Blog Entry2:

<user name/email>

<comments>

 

<user name2/email>

<comments>

----------------------------------------------------------------------------------------------------

any help is greatly appreciated! this is the firt time i'm creating a comments box, and using PHP.

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.