Ver Mensaje Individual
  #2 (permalink)  
Antiguo 20/12/2007, 08:45
darkxer0x
 
Fecha de Ingreso: junio-2006
Mensajes: 270
Antigüedad: 17 años, 10 meses
Puntos: 0
Re: Como mejorar esta funcion?

Código:
<?php

// Sample function to recursively return all files within a directory.
// http://www.pgregg.com/projects/php/c...e_readdir.phps

Function listdir($start_dir='.') {

  $files = array();
  if (is_dir($start_dir)) {
    $fh = opendir($start_dir);
    while (($file = readdir($fh)) !== false) {
      # loop through the files, skipping . and .., and recursing if necessary
      if (strcmp($file, '.')==0 || strcmp($file, '..')==0) continue;
      $filepath = $start_dir . '/' . $file;
      if ( is_dir($filepath) )
        $files = array_merge($files, listdir($filepath));
      else
        array_push($files, $filepath);
    }
    closedir($fh);
  } else {
    # false if the function was called with an invalid non-directory argument
    $files = false;
  }

  return $files;

}

$files = listdir('.');
print_r($files);
?>
En la pagina de php tienes post de gente que postea metodos