开发者

How to take a string after the slash?

Like:

"http://www.blog-name.com/search/taio cruz"

---------------------------------------------^

"Sorry, no posts were found with the tag taio cruz"

The Problem:

If the user enters http://www.blog-name.com/search/taio cr开发者_开发技巧uz, the browser will look for a folder named "taio cruz", won't it ?

How can I get the value "Taio Cruz"?


echo basename("http://www.blog-name.com/search/taio cruz"); //taio cruz


$url = 'http://www.blog-name.com/search/taio cruz';
$val = end(explode('/', $url));
// $val is now 'taio cruz'


$url = 'http://www.blog-name.com/search/taio cruz';
$last = substr($url, strrpos($url, '/') + 1);
//$last is now "taio cruz"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜