开发者

How to take a string after the slash?

开发者 https://www.devze.com 2023-03-06 09:34 出处:网络
Like: \"http://www.blog-name.com/search/taio cruz\" ---------------------------------------------^ \"Sorry, no posts were found with the

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

精彩评论

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