我的数据库里有这种类型的链接

http://fo.website1.com/image/2584372/600full-name.jpg

我要将此链接转换为此链接
http://website2.com/pic/25/84/37/2/600full-name.jpg

我知道用一行sql replace就可以完成第一部分,也就是说,到这一部分为止,我没有任何问题http://fo.website1.com/image/可以很容易地完成
UPDATE tableA set link= replace(link, "http://fo.website1.com/image/", "http://website2.com/pic/")

但我更关心的是下一步该如何实现
这个数字的范围从1到10000000,对于每两位之后我创建的子文件夹中的每个数字/
例如343433将进入34/34/33,就像6456454将进入64/56/45/4一样
你知道我该怎么做吗
我就这样分开了
  $c1=explode("/",$websitelink,-1);  $city1=end($c1);

  $f1=substr($city1, 0, 2);

  $f2=substr($city1, 2, 2);

  $f3=substr($city1, 4, 2);

  $f4=substr($city1, 6, 10);

希望用上面给出的所需号码替换website1号码,并且不想触碰其他号码
   Kurbaan HD Movie Wallpaper #1 way2enjoyKurbaan 1024x768 Wallpaper # 1Wallpapers[img]http://iv1.website1.com/image/6661434/600full-justin-timberlake.jpg[/img][img]http://media1.santabanta.com/full1/Bollywood%20Movies/All%20the%20Best/all-the-best-0a.jpg[/img][img]http://media1.santabanta.com/full1/Bollywood%20Movies/Do%20Knot%20Disturb/do-knot-disturb-0a.jpg[/img][img]http://media1.santabanta.com/full1/Bollywood%20Movies/London%20Dreams/london-dreams-8e.jpg[/img][img]http://iv1.website1.com/image/1661434/600full-justin-timberlake.jpg[/img][img]http://media1.santabanta.com/full1/Global%20Celebrities(F)/Hope%20Dworaczyk/hope-dworaczyk-7a.jpg[/img]

最佳答案

一旦你有了号码(使用你的代码):

$c1=explode("/",$websitelink,-1);
$city1=end($c1);

尝试改用str_split()然后join()创建新路径:
$output = str_split($city1, 2);
$path = join('/', $output);

343433将返回34/34/33,6456454将返回64/56/45/4

10-04 10:26