This is a translated page. The original can be found here: http://iwebdevel.com/2009/06/16/php-get-all-files-and-folders-from-a-directory-folder/
UPDATES VIA RSS | Email Ενημέρωση μέσω RSS | Email Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… Αρχική Σελίδα / Κωδικοποίηση / PHP / PHP: Πάρτε όλα τα αρχεία και folde ...

PHP: Get all files and folders from a directory (folder) PHP: Βρείτε όλα τα αρχεία και τους φακέλους από έναν κατάλογο (φάκελο)

Posted on 16. Καταχωρήθηκε στις 16. Jun, 2009 by Dragos in Coding , PHP Ιούνιος, 2009 από Dragos στο Κωδικοποίηση, PHP

To get all files and folders from a directory (folder) I found scandir to be the perfect solution. Για να πάρετε όλα τα αρχεία και τους φακέλους από έναν κατάλογο (φάκελο) Βρήκα scandir να είναι η τέλεια λύση.

scandir scans a directory and returns an array containing all files and directories under the parent directory we're looking in. scandir σαρώνει έναν κατάλογο και επιστρέφει έναν πίνακα που περιέχει όλα τα αρχεία και τους καταλόγους κάτω από τον κατάλογο μητρική ψάχνουμε in.

The code below will try to remove a directory, if the element is a directory or delete a file, if respectively the element is a file. Οι παρακάτω κώδικα θα προσπαθήσει να αφαιρέσετε έναν κατάλογο, αν το στοιχείο είναι ένας κατάλογος ή να διαγράψετε ένα αρχείο, αντίστοιχα, αν το στοιχείο είναι ένα αρχείο.

 $lookin='./home/folder'; $ lookin = '. / home / folder'?
$elements=scandir($lookin); = $ στοιχεία scandir ($ lookin)?
foreach($elements as $singleEl) { foreach ($ $ στοιχεία ως singleEl) (
     if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); if (is_dir ($ lookin .'/'.$ singleEl)) rmdir ($ lookin .'/'.$ singleEl)?
     else άλλος
     unlink($lookin.'/'.$singleEl); unlink ($ lookin .'/'.$ singleEl)?
} ) 
Translate this post Μεταφράστε αυτήν την θέση


Related posts: Σχετικές θέσεις:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess Apache & ModRewrite: Πώς να αρνηθεί την εύκολη πρόσβαση σε ένα φάκελο με htaccess
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? JavaScript: Πώς να πάρετε το δείκτη (θέση σε μια ομάδα) ενός αντικειμένου με jQuery;
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? JavaScript: Πού μπορώ να βρω τα ακίνητα για όλα τα στοιχεία HTML;
  4. PHP: How to get creation time of file with PHP on Linux machines PHP: Πώς να πάρει χρόνο δημιουργία του αρχείου με την PHP σε Linux μηχανές
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script Wordpress: Καλύτερη iTranslator SEO για Wordpress, αποκτήσετε δωρεάν κυκλοφορίας από το πλήρως αυτοματοποιημένο πρόγραμμα plugin

    blog comments powered by Disqus blog παρατηρήσεις που κινούνται με Disqus