Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> Sprawdzanie Czy Katalog Jest Pusty
Cyberbo
post
Post #1





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 26.01.2003

Ostrzeżenie: (0%)
-----


no wlasnie... jak sprawdzic czy dany katalog jest pusty... czy mozna go usunac... (IMG:http://forum.php.pl/style_emoticons/default/questionmark.gif)
Go to the top of the page
+Quote Post
stoprocent
post
Post #2





Grupa: Zarejestrowani
Postów: 338
Pomógł: 2
Dołączył: 17.05.2003
Skąd: Kraków , Londyn

Ostrzeżenie: (0%)
-----


  1. <?php
  2.  
  3. // SPRAWDZANIE KATALOGU
  4. $folder = scandir($dir);
  5. if(empty($folder))
  6. {
  7. echo 'katalog jest pusty';
  8. rmdir($dir) //USUWANIE KATALOGU 
  9. }else{
  10.  
  11. echo 'katalog nie jest pusty';
  12. }
  13. ?>
Go to the top of the page
+Quote Post
Cyberbo
post
Post #3





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 26.01.2003

Ostrzeżenie: (0%)
-----


scandir działa tylko pod PHP5
Go to the top of the page
+Quote Post
stoprocent
post
Post #4





Grupa: Zarejestrowani
Postów: 338
Pomógł: 2
Dołączył: 17.05.2003
Skąd: Kraków , Londyn

Ostrzeżenie: (0%)
-----


  1. <?php
  2.  
  3. // SPRAWDZANIE KATALOGU
  4. $folder = opendir($dir);
  5. $folder = readdir($folder);
  6. if(empty($folder))
  7. {
  8. echo 'katalog jest pusty';
  9. rmdir($dir) //USUWANIE KATALOGU
  10. }else{
  11.  
  12. echo 'katalog nie jest pusty';
  13. }
  14.  
  15. ?>
Go to the top of the page
+Quote Post
Cyberbo
post
Post #5





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 26.01.2003

Ostrzeżenie: (0%)
-----


niby jest ok, ale pokazuje, że katalog nie jest pusty nawet gdy tak jest :|
Go to the top of the page
+Quote Post
mike
post
Post #6





Grupa: Przyjaciele php.pl
Postów: 7 494
Pomógł: 302
Dołączył: 31.03.2004

Ostrzeżenie: (0%)
-----


  1. <?php
  2. $resDir = opendir($strDir);
  3. while( $strFile = readdir( $resDir ) )
  4. {
  5.     $arrFiles[] = $strFile;
  6. }
  7. if( sizeof( $arrFiles ) <= 2 )
  8. {
  9.     echo 'katalog jest pusty';
  10.     rmdir($strDir) //USUWANIE KATALOGU
  11. }
  12. else
  13. {
  14.     echo 'katalog nie jest pusty';
  15. }
  16. ?>
Go to the top of the page
+Quote Post
Cyberbo
post
Post #7





Grupa: Zarejestrowani
Postów: 22
Pomógł: 0
Dołączył: 26.01.2003

Ostrzeżenie: (0%)
-----


A no właśnie... (IMG:http://forum.php.pl/style_emoticons/default/smile.gif) "." i ".." (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif)

WIELKIE DZIKI (IMG:http://forum.php.pl/style_emoticons/default/smile.gif)

P.S. Gdzieś zniknęła funkcja "pomógł"? :|
Go to the top of the page
+Quote Post
hwao
post
Post #8


Developer


Grupa: Moderatorzy
Postów: 2 844
Pomógł: 20
Dołączył: 25.11.2003
Skąd: Olkusz




A nie lepiej poprostu usunac bez wzgledu na to czy cos jest czy nie ? (czyli usunac kaytalog bez znaczenia czy cos jest w srodku czy nie (IMG:http://forum.php.pl/style_emoticons/default/tongue.gif) )
http://webcity.pl/webcity/porady.php/t/70
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 22.12.2025 - 23:56