从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.
我有以下字符串为我网站上的音乐播放器生成mp3网址。 p>
&lt;?php echo $ song-&gt; getTitle()?&gt;
code> pre>
导致 / public / music_song / df / 74 / 746b_2112.mp3?c = ec1e strong> p>
我想从 / public / music_song / df / 74中的字符串
resulting中删除查询 /746b_2112.mp3
nn我已经研究了如何分割网址,但我还没有成为一个php天才,所以我不知道天气要分裂或 使用preg_replace或如何将它合并到我现有的字符串中。 p>
我必须摆脱这些查询,它们是不必要的,并且每天都会崩溃我的数据库。 p>
div>
$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 )); ?>
list($keep) = explode('?', '/public/music_song/df/74/746b_2112.mp3?c=ec1e');