Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何加上「;拇指“;在使用php创建图像url的最后一部分之前?_Php_Url_Thumbnails - Fatal编程技术网

如何加上「;拇指“;在使用php创建图像url的最后一部分之前?

如何加上「;拇指“;在使用php创建图像url的最后一部分之前?,php,url,thumbnails,Php,Url,Thumbnails,我的url如下所示: http://mydomain/filemanager/photos/shares/xxxx/image.jpg 我需要将此图像url转换为: http://mydomain/filemanager/photos/shares/xxxx/thumbs/image.jpg 我该怎么做?如果您知道文件名(即image.jpg)是什么: str_replace('image.jpg','thumbs/image.jpg',$fullPath) 查找文件名相当容易: basenam

我的url如下所示:

http://mydomain/filemanager/photos/shares/xxxx/image.jpg

我需要将此图像url转换为:
http://mydomain/filemanager/photos/shares/xxxx/thumbs/image.jpg


我该怎么做?

如果您知道文件名(即
image.jpg
)是什么:

str_replace('image.jpg','thumbs/image.jpg',$fullPath)

查找文件名相当容易:

basename($fullPath)

把它放在一起

$fileName = basename($fullPath);
$newFileName = 'thumbs/' . $filename;
$newPath = str_replace($filename, $newFileName, $fullPath);

到目前为止你试过什么?