替换文件路径字符串中间的目录
$string = 'http://example.com/category/1/news/2134/'; // '1' is dynamic
如何将1
更改为我想要的任何数字?
无法调用字符串的一部分,它只是一个类似文本的变量。
可以使用一些真正的正则表达式来完成。
$string = 'http://example.com/category/1/news/2134/'; // '1' is dynamic
How can I change 1
to any number I want?
Can't call parts of the string, its just a text-like variable.
It can be done with some true regex.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果没有更多信息,我对您问题的最佳猜测是:
Without more information, my best guess at your problem is :
[编辑]
@People downvoting,这种方法似乎有什么问题?
[edit]
@People downvoting, what seems to be the problem with this approach?
这会将数字替换为 56。
此方法使用带有 断言。
This replaces the number by 56.
This approach uses a regex with assertions.