dtwye28880 2012-05-01 19:39
浏览 27
已采纳

从php中生成的url字符串中删除不需要的查询

I have the following string generating mp3 urls for a music player on my site.

<?php echo $song->getTitle() ?>

which results in /public/music_song/df/74/746b_2112.mp3?c=ec1e

I would like to remove the query from the string resulting in /public/music_song/df/74/746b_2112.mp3

I've looked into how to split the url, but I'm nowhere near being a php genius just yet so I dont know weather to split or use preg_replace or how the heck to incorporate it into my existing string.

I have to get rid of these queries, they are unneeded and crashing my databases on a daily basis.

  • 写回答

2条回答 默认 最新

  • doujiu3768 2012-05-01 20:51
    关注
    $parsedInput = parse_url('/public/music_song/df/74/746b_2112.mp3?c=ec1e');
    echo $parsedInput['path'];
    // Results in /public/music_song/df/74/746b_2112.mp3
    

    Edit: Since I havent worked with SocialEngine, Im guessing that what you need to do is:

    <?php $parsed = parse_url($song->getFilePath());
          echo $this->htmlLink($parsed['path'], 
                               $this->string()->truncate($song->getTitle(), 50), 
                               array('class' => 'music_player_tracks_url', 
                                     'type' => 'audio', 
                                     'rel' => $song->song_id )); ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看