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 التحديثات عن طريق آر إس إس | البريد الالكتروني Get updates via feedburner Get updates via twitter
Home / Coding / PHP / PHP: Get all files and folde… الوطن / الترميز / [فب] / [فب] : احصل على جميع الملفات وfolde...

PHP: Get all files and folders from a directory (folder) [فب] : احصل على جميع الملفات والمجلدات من دليل (مجلد)

Posted on 16. نشر في 16. Jun, 2009 by Dragos in Coding , PHP يونيو ، 2009 من قبل دراكوش في الترميز ، [فب]

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); لفك ($ تبدو.'/'.$ singleEl) ؛ 
 } ) 
Translate this post ترجمة هذه الوظيفة


Related posts: الوظائف ذات الصلة :

  1. Apache & ModRewrite: How to easily deny access to a folder with htaccess اباتشي & ModRewrite : كيفية منع الوصول بسهولة إلى مجلد مع هتكس
  2. JavaScript: How to get the index (position within a group) of an object with jQuery? جافا سكريبت : كيفية الحصول على مؤشر (الموقف داخل مجموعة) للجسم مع jQuery؟
  3. JavaScript: Where do I Find All Properties for All HTML Elements ? جافا سكريبت : أين يمكنني إيجاد جميع خصائص لجميع عناصر أتش تي أم أل؟
  4. PHP: How to get creation time of file with PHP on Linux machines [فب] : كيفية الحصول على الوقت لإنشاء ملف مع بي على لينكس آلات
  5. Wordpress: Best SEO iTranslator for Wordpress, get free traffic from fully automated plugin script وورد : أفضل كبار المسئولين الاقتصاديين iTranslator لورد ، والحصول على حرية الحركة من مؤتمتة بالكامل النصي المساعد

    blog comments powered by Disqus بلوق التعليقات مدعوم من ديسقوس]