开发者

PHP substr Query - Cropping URL

I currently have the string: "/en/sports/football/"

How do I substr this string to achieve:

"/sports/football/"

Man开发者_开发技巧y thanks for any pointers.


Well, lets take a look: http://php.net/manual/en/function.substr.php

The method signature looks something like this:

string substr ( string $string , int $start [, int $length ] )

If length is omitted, the substring starting from start until the end of the string will be returned.

So I guess we could do something like this to get characters 3 and onward.

substr("/en/sports/football/", 3);


explode() on '/', discard the directory you don't want, then implode() on '/'

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜