If you want to copy all files recursively from a source directory to some destination :
$directory = new RecursiveDirectoryIterator("./source_path/");
foreach (new RecursiveIteratorIterator($directory) as $filename=>$current) {
$src = $current->getPathName();
$dest = "./destination_path/" . $current->getFileName();
echo "copy " . $src . " => " . $dest . "\n";
copy($src, $dest);
}
I hope it can help someone because when I looked for this solution I had to transform another example to get it.