KrisGeor KrisGeor - 6 months ago 58
HTML Question

How to get string from a file using php

Ok so I have a txt file (mytxt.txt)

Content inside is saved like this

name (username)
name (username)

And I'm trying to get these lines and put them in a HTML
element but I can't figure out how

What im trying to do is to get every line of the document to echo in a difrent
HTML element

Answer Source

You can read a file with php like this:

$myfile = fopen("mytxt.txt", "r") or die("Unable to open file!");
while( !feof( $myfile ) ) {
?> <li> <?php echo fgets($myfile); ?> </li>


just place this inside the element that you want the info to echo into.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download