简体   繁体   中英

PHP substr Query - Cropping URL

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

How do I substr this string to achieve:

"/sports/football/"

Many 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() ,丢弃不需要的目录,然后在'/'上implode()

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM