我使用parse_url()来获取url的路径,但我想删除第一个斜杠&最后一个如果它存在.
例:
"/posts/funny-dog/" -> "posts/funny-dog" "/" -> "" // Because http://www.google.com/ path is a slash "/categories/politic" -> "categories/politics"
谢谢
修剪($str,“/”);可能是你最好/最快的赌注.