Question

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.

Your help would be appreciated.

Était-ce utile?

La solution

you may want to look at php's function nl2br

<?php print nl2br($filecontents);?>

Autres conseils

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);?>

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>"; ?>
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top