dsbiw2911188 2014-02-27 00:47
浏览 23
已采纳

从最后一个输出中删除文本

I'm working on a mp3 player for my website that is "database driven".
However I'm up against a "small" issue when i output the data for the playlist for the mp3 player.

First off i can say it's an embedded mp3 player that uses this code to add another song to
the playlist: %20%7C

Example: song1.mp3%20%7Csong2.mp3

So for adding songs i figured i would use mysql and php to add songs to the playlist using this code:

Code:

foreach ($stmt as $row) 
{
  $music .= "".$row['song']."%20%7C";   
}

Which works with the playlist, but the problem is that it adds another song with no title or sound hence the %20%7C at the end.

So I'm wondering if it is possible to check if it's the last output and remove %20%7C from it so it only list the amount of songs i have in the database?

  • 写回答

3条回答 默认 最新

  • dougu3290 2014-02-27 00:56
    关注

    after loop, just

    $music=rtrim($music,"%20%7C"); 
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥60 pb数据库修改或者求完整pb库存系统,需为pb自带数据库
  • ¥15 spss统计中二分类变量和有序变量的相关性分析可以用kendall相关分析吗?
  • ¥15 拟通过pc下指令到安卓系统,如果追求响应速度,尽可能无延迟,是不是用安卓模拟器会优于实体的安卓手机?如果是,可以快多少毫秒?
  • ¥20 神经网络Sequential name=sequential, built=False
  • ¥16 Qphython 用xlrd读取excel报错
  • ¥15 单片机学习顺序问题!!
  • ¥15 ikuai客户端多拨vpn,重启总是有个别重拨不上
  • ¥20 关于#anlogic#sdram#的问题,如何解决?(关键词-performance)
  • ¥15 相敏解调 matlab
  • ¥15 求lingo代码和思路