我的网页位于http://www.example.com/product/
。它在列表中有数百种产品。每个产品都有一个URL,并相应地链接到详细页面。我想批量更新这些链接的域名。
例如,在产品列表中,我有:
http://www.example.com/htc/desire
http://www.example.com/htc/widlfire
http://www.example.com/motorola/atrix
我想将它们更改为:
http://www.another-server.com/htc/desire
http://www.another-server.com/htc/widlfire
http://www.another-server.com/motorola/atrix
注意:链接由PHP动态生成,而不是硬编码。
如何批量更新这些链接的域名?
答案 0 :(得分:0)
一个简单的str_replace?
$var = 'http://www.example.com/motorola/atrix';
$new = str_replace('example.com', 'anothers-erver.com', $var);
echo $new; //http://www.anothers-erver.com/motorola/atrix
答案 1 :(得分:-2)
记事本中的“全部替换”可能会成功,你不觉得吗?