在网页中截断来自php的输出

I want to get the list of trams coming by my house. I have a python script that takes the times and spits them out. On every line there is the tram number , the next one is then on a new line.

$ /var/www/html/kvvliveapi.py departures de:8212:31
sofort  S1 Bad Herrenalb||||

1 min   3 Heide||||

1 min   3 Tivoli über Hbf||||

3 min   S2 Spöck||||

3 min   2 Wolfartsweier||||

I want to have this in a web page, so I run the script with php.

(in index.html)

<?php 
exec('python /var/www/html/kvvliveapi.py departures de:8212:31', $out);
echo implode("
", $out);
?> 

But then on the webpage it looks really weird. It doesn't have all the lines it has, when I run it in the terminal, and although I have new lines, on the web page everything is on one line.

sofort S1 Bad Herrenalb|||| 1 min 3 Heide||||

This same worked for me

Solution 1:

Change this to

echo implode("
", $out);

This:

print_r(implode("<br>",$out));

Solution2:

Change this to:

echo implode("
", $out);

This:

echo "<pre>";
echo implode("
", $out);
echo "</pre>";