I have following Array with filenames. Array is saved under var $files.
我有跟随文件名的数组。数组保存在var $ files下。
array (
[0] => DSC02425.jpg
[1] => DSC02426.jpg
[2] => DSC02432.jpg
[3] => DSC02437.jpg
)
I want to copy this files from one to another folder, but how can i achive this? I made a function but it isnt working:
我想将这些文件从一个文件夹复制到另一个文件夹,但我怎么能这样呢?我做了一个功能,但它不起作用:
function copyFiles($array) {
for ($i = 0;$i < count($array);$i ++) {
copy("./" . $array[$i] , "/$folderlabel/" . $array[$i]);
}
}
copyFiles($files);
1 个解决方案
#1
0
Corrected function:
function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}
#1
0
Corrected function:
function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}