Link to home
Create AccountLog in
Avatar of rgb192
rgb192Flag for United States of America

asked on

delete the empty lines and include html

data looks like this: I do not have it in a database

data

<h3>more data</h3>
<p>data</p>

words

data

Open in new window


want this as output (including html)
data
<h3>more data</h3>
<p>data</p>
words
data

Open in new window



this code works but does not echo the html properly
<?php
$lines = file("sourcefile.txt");
foreach($lines as $line)
{
  if(trim($line) != "")
  {
    echo $line;
  }
}
?>
                                            

Open in new window



note: I do not want to combine lines

so every line would have a linebreak <br/>

maybe like this

  if(trim($line) != "")
  {
    echo '<br>'.$line;
  }
ASKER CERTIFIED SOLUTION
Avatar of Ray Paseur
Ray Paseur
Flag of United States of America image

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of rgb192

ASKER

thanks
Thanks for the points!
Avatar of rgb192

ASKER

thanks for the teaching