php preg_替换这个网址
我想在数组插入 mysql 表之前替换这个 url。 我有标题描述和数组中的链接,并且链接有太多“垃圾”
这是 var_dump($item["link"]); 的示例看起来像: [“链接”]=> string(88) "http://www.hello.com/junk/junk-ju-junkj-junk-jun-ju-junk,-JU-1234"
我想像这样替换链接: [“链接”]=> string(88) "http://www.hello.com/te/tst?te=1234"
因此搜索 "http://www.hello.com" 和 "very last '-' ...before 1234 之间的所有内容” 并将其替换为“/te/tst?te=”
在插入 mysql 表之前如何替换它?
预先感谢您的专业知识和时间;)
I want to replace this url, before array gets inserted in mysql table.
I have title description and link in array, and link has too much "junk"
Here is sample of what var_dump($item["link"]); looks like:
["link"]=> string(88) "http://www.hello.com/junk/junk-ju-junkj-junk-jun-ju-junk,-JU-1234"
I would like to get link replaced like this:
["link"]=> string(88) "http://www.hello.com/te/tst?te=1234"
So search everything between "http://www.hello.com" and "very last '-' ...before 1234"
and replace it with "/te/tst?te="
How do I replace this before it gets inserted in mysql table?
Thank you in advance for your expertise and time ;)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

您预计除“com”之外还有其他顶级域名吗?假设
你能做到
你会得到
Do you anticipate other top-level domains other than 'com'? Assuming
You can do
You'll get