我目前有字符串:“/en/sports/football/”
我如何 substr 这个字符串来实现:
“/体育/足球/”
非常感谢您的任何指点。
好吧,让我们看看: http: //php.net/manual/en/function.substr.php
方法签名看起来像这样:
字符串 substr ( 字符串 $string , int $start [, int $length ] )
如果省略长度,则返回从 start 到字符串结尾的子字符串。
所以我想我们可以做这样的事情来获得字符 3 及以后的字符。
substr("/en/sports/football/", 3);
explode()
在“/”上,丢弃您不想要的目录,然后implode()
在“/”上