PHP Classes

File: get_all_folder_names.php

Recommend this page to a friend!
  Classes of Jill Lingoff   Sweeper   get_all_folder_names.php   Download  
File: get_all_folder_names.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Sweeper
Clean HTML to remove unwanted tags and attributes
Author: By
Last change:
Date: 5 years ago
Size: 1,352 bytes
 

Contents

Class file image Download
<?php

print('<meta charset="utf-8" />
'
);
$folders = array();
$source = 'not-swept';
$folders = recursive_list($source, $folders);
print(
'$folders: ');var_dump($folders);

function
recursive_list($source, $folders) {
    if(
is_dir($source)) {
       
//print("here394950560<br>\r\n");exit(0);
       
$d = dir($source);
        while(
FALSE !== ($entry = $d->read())) {
            if(
$entry == '.' || $entry == '..') {
                continue;
            }
           
$Entry = $source . '/' . $entry;
           
//print("***" . $Entry . "<br>\r\n");
           
if(is_dir($Entry)) {
               
$folder = $Entry;
               
$folder = str_replace('not-swept/', '', $folder);
               
$folder = substr($folder, strpos($folder, '/', strpos_last($folder, '/') - strpos($folder, '/')));
               
$folders[$folder] = true;
               
$folders = recursive_list($Entry, $folders);
               
//continue;
           
}
        }
       
$d->close();
    }
    return
$folders;
}

function
file_extension_is($filename, $extension) {
   
$found_extension = substr($filename, strpos_last($filename, '.'));
    if(
$found_extension === $extension) {
        return
true;
    }
    return
false;
}

function
strpos_last($haystack, $needle) {
   
//print('$haystack, $needle: ');var_dump($haystack, $needle);
   
if(strlen($needle) === 0) {
        return
false;
    }
   
$len_haystack = strlen($haystack);
   
$len_needle = strlen($needle);
   
$pos = strpos(strrev($haystack), strrev($needle));
    return
$len_haystack - $pos - $len_needle;
}

?>