dongtanliefang8765 2017-04-08 09:06
浏览 31
已采纳

在网页中截断来自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||||
  • 写回答

1条回答 默认 最新

  • doulongsha5478 2017-04-08 09:17
    关注

    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>";
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效