需要帮助。
function move_images($dir_source,$dir_target){
$files = glob($dir_source);
foreach($files as $file){
if(is_file($file))
copy($file,$dir_target.basename($file));
unlink($file);
}
return true;
}
move_images('temp/*','../images/');
我收到这个消息:
警告:中为foreach()提供的参数无效/home/rescraboo/public_html/inc/functions.php第75行
事实上,当"temp"目录中有一个文件时,它工作得很好。那么,当temp为空时,如何跳过这个?
感谢
事实上,当"temp"目录中有一个文件时,它工作得很好。那么,当temp为空时,如何跳过这个?
不需要检查目录/数组是否为空,如果是空的话,它就不会遍历foreach循环。
但你必须确保你的目录是可读的,你可以用is_readable()
来检查。