【发布时间】:2013-09-19 11:52:46
【问题描述】:
我有以下代码。
if ($_GET['dir']!=''){
$checkifhasfiles = array_diff(scandir($_GET['dir']), array(".","..","error_log"));
foreach($checkifhasfiles as $cihf){
if(is_file($_GET['dir'].'/'.$cihf)){
echo "Ok, the folder has files";
}
}
}
如果文件夹包含only 文件,我想做的只是显示one 消息。问题是,正如预期的那样,foreach 正在为文件夹包含的每个文件“回显”一条消息。
我怎样才能“绕过”它,如果文件夹有文件,则只打印一条消息?
感谢和问候
顺便说一句 - 很抱歉缩进,我正在记事本上写,因为我不在家,而且缩进不完美
【问题讨论】:
标签: php file foreach directory