gpt4 book ai didi

php - 替换 "/"之前的任何字符串,PHP

转载 作者:可可西里 更新时间:2023-11-01 00:04:18 25 4
gpt4 key购买 nike

无论字符串长度如何,我都想替换“/”之前的任何字符串。

谢谢让

最佳答案

一种方式,假设您想更改第一个“/”之前的字符串。

$str = "anystring/the_rest/blah";
$s = explode("/",$str);
$s[0]="new string";
print_r ( implode("/",$s) );

关于php - 替换 "/"之前的任何字符串,PHP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2279288/

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