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

报告相同问题?

悬赏问题

  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料