list=array(); $__regexp=preg_quote($__pattern,"/"); $__regexp=preg_replace("/[\\x5C][\x2A]/",".*",$__regexp); $__regexp=preg_replace("/[\\x5C][\x3F]/",".", $__regexp); if(is_dir($__dir)) if(($__dir_h=@opendir($__dir))!==FALSE) { while(($__file=readdir($__dir_h))!==FALSE) if(preg_match("/^".$__regexp."$/",$__file)) array_push($this->list,$__file); closedir($__dir_h); sort($this->list,SORT_STRING); } } function toArray() { return $this->list; } function getLast() { return $this->list[count($this->list)-1]; } function array_flat($array) { foreach($array as $a) { if(is_array($a)) { $tmp = array_merge($tmp, $this->array_flat($a)); }else { $tmp[] = $a; } } return $tmp; } function recursive($dir) { $files = array(); if ($handle = opendir($dir)) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != "..") { if(is_dir($dir.'/'.$file)) { $dir2 = $dir.'/'.$file; $files[]=$dir2.'/'; $files[] = $this->recursive($dir2); } else { $files[] = $dir.'/'.$file; } } } closedir($handle); } return $this->array_flat($files); } }