문제

I have following Array with filenames. Array is saved under 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);
도움이 되었습니까?

해결책

Corrected function:

function copyFiles($array,$sourcePath,$savePath) {
for($i = 0;$i < count($array);$i++){
    copy($sourcePath.$array[$i],$savePath.$array[$i]);}
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top