我有这个网址:
http://localhost/cms/uploads/files/1/images/hd-wallpaper-40.jpg
Run Code Online (Sandbox Code Playgroud)
并需要转换为:(在1之前删除所有网址)
1/images/hd-wallpaper-40.jpg
Run Code Online (Sandbox Code Playgroud)
编辑:
http://localhost/cms/uploads/files/ 是动态所以也许: http://localhost/uploads/files/
怎么能用php转换这个url?
我不知道你需要的规则/条件,但这是一种方式:
$url = parse_url('http://localhost/cms/uploads/files/1/images/hd-wallpaper-40.jpg');
echo str_replace('/cms/uploads/files/', '', $url['path']);
Run Code Online (Sandbox Code Playgroud)
更新:
如果images是静态的:
$url = parse_url('http://localhost/cms/uploads/files/1/images/hd-wallpaper-40.jpg');
preg_match('/[0-99999]\/.*/', $url['path'], $matches);
echo $matches[0];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1136 次 |
| 最近记录: |