我需要删除所有字符 最后一个Url斜杠
我的网址:
http://www.example.com/page_with_loop/articel
我需要输出的PHP代码:
http://www.example.com/page_with_loop/
答案 0 :(得分:0)
也许是这样的:
$urlInput = "http://example.com/category/article";
$urlDeletePos = strlen($urlInput) - strlen(strrchr($urlInput));
$urlOutput = substr($urlInput,0,$urlDeletePos);
echo "Shortened URL is $urlOutput";