Показать сообщение отдельно

  #2  
Старый 09.03.2010, 20:46
Deathdreams
Постоянный
Регистрация: 08.11.2008
Сообщений: 498
Провел на форуме:
2603363

Репутация: 278
Отправить сообщение для Deathdreams с помощью ICQ
По умолчанию

Для одной папки:
Код:
$path = '/path'; //без слеша на конце
$ext = 'ini'; // без точки

if ($handle = opendir($path)) {

    while (false !== ($file = readdir($handle))) {
        $this_ext = end(explode(".", $file));
                if( $this_ext == $ext ) if( @unlink($path."/".$file) ) { echo $path."/".$file." - success deleted!\r\n"; } else { echo $path."/".$file." - i can't delete this file\r\n"; }
    }

    closedir($handle);

} else { die('Can\'t open folder "'.$path.'"'); }
Для массива папок:

Код:
$paths = array('/path', '/tmp', '/home/www'); // везде без слеша на конце
$ext = 'ini'; // без точки

foreach( $paths as $n => $path ) {

if ($handle = opendir($path)) {

    while (false !== ($file = readdir($handle))) {
        $this_ext = end(explode(".", $file));
        if( $this_ext == $ext ) if( @unlink($path."/".$file) ) { echo $path."/".$file." - success deleted!\r\n"; } else { echo $path."/".$file." - i can't delete this file\r\n"; }
       }

    closedir($handle);
   }  else { echo 'Can\'t open folder "'.$path.'"'; }

}

Последний раз редактировалось Deathdreams; 09.03.2010 в 21:24..