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 | אימייל Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… דף הבית / Coding / 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 סריקות ספרייה ומחזירה מערך המכיל את כל הקבצים והספריות בספרייה תחת ההורה אנחנו מסתכלים פנימה

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'; הביתה מסתכל $ = ". / / תיקייה";
$elements=scandir($lookin); אלמנטים $ = scandir ($ מחפש);
foreach($elements as $singleEl) { אלמנטים foreach ($ $ כמו singleEl) (
     if(is_dir($lookin.'/'.$singleEl)) rmdir($lookin.'/'.$singleEl); אם (is_dir ($ לחפש .'/'.$ singleEl)) rmdir ($ לחפש .'/'.$ singleEl);
     else אחר
     unlink($lookin.'/'.$singleEl); unlink ($ לחפש .'/'.$ singleEl);
} ) 
Translate this post תרגם פירסום


Related posts: הודעות קשורות:

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess אפאצ 'י & 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 על מכונות לינוקס
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script וורדפרס: Best iTranslator SEO עבור וורדפרס, מקבלים תנועה חופשית סקריפט תוסף אוטומטי לחלוטין

    blog comments powered by Disqus תגובות לבלוג powered by Disqus