-1

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 <li> 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 <li> HTML element

3

1 Answer 1

2

You can read a file with php like this:

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

fclose($myfile);
?>

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

2
  • I want every line of the document to echo in a difrent <li> element
    – KrisGeor
    Aug 24, 2017 at 0:46
  • 1
    If that worked for you can you please mark as answer?
    – Mr.Lister
    Aug 24, 2017 at 1:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.