Printing .txt file content vertically in php

I am using:

<?php $emails = get_stylesheet_directory_uri().'/files/emails.txt'; ?>
<?php $filecontents = file_get_contents($emails);?>
<?php print $filecontents;?>

to print out contents inside a text file. The printed out text should be displayed vertically just like it is displayed inside the text file but it is displayed horizontally once printed out.

Read More

Your help would be appreciated.

Related posts

Leave a Reply

3 comments

  1. Instead of getting that in file_get_contents , grab that under file() and then implode() it up using a <br> tag.

    <?php $filecontents = file($emails);?>
    <?php print implode('<br>',$filecontents);?>
    
  2. HTML requires use of the <br> tag to create line breaks (or block level elements). In your code you aren’t doing anything to indicate you want a new line. Not even a new line character n.

    <?php echo "'".$emails."'<br>"; ?>