gpt4 book ai didi

php - 删除重复的尾部斜杠

转载 作者:可可西里 更新时间:2023-10-31 23:52:07 25 4
gpt4 key购买 nike

我想用 php 检测像 $string 这样的字符串是否包含重复的尾部斜杠。

例如:

$string = "http://somepage.com/something/some.html/////";

$string = "http://somepage.com/something/some.html";

我想做一个if,如果它有重复,像这样:

If ($string = "http://somepage.com/something/some.html/////";) {
remove extra trailing slashes
}
//else do nothing...

最佳答案

申请rtrim像这样

$string = rtrim($string, '/');

关于php - 删除重复的尾部斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13990256/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com