1

我目前有字符串:“/en/sports/football/”

我如何 substr 这个字符串来实现:

“/体育/足球/”

非常感谢您的任何指点。

4

2 回答 2

1

好吧,让我们看看: http: //php.net/manual/en/function.substr.php

方法签名看起来像这样:

字符串 substr ( 字符串 $string , int $start [, int $length ] )

如果省略长度,则返回从 start 到字符串结尾的子字符串。

所以我想我们可以做这样的事情来获得字符 3 及以后的字符。

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

于 2011-02-12T12:01:54.663 回答
0

explode()在“/”上,丢弃您不想要的目录,然后implode()在“/”上

于 2011-02-12T12:07:47.380 回答