Hace unos dias consultaba sobre la forma de obtener una lista con los nombres de todas las carpetas de un directorio.
Mi duda ahora es para guardar esos datos en un array, además de su fecha de creacion y modificación.
El script es el siguiente:
Código PHP:
$ruta='documentos/';
$lista = array();
if ($carpeta=opendir($ruta))
{
while (($file = readdir($carpeta)) !== false)
{
if (is_dir($ruta.$file) && $file != '.' && $file != '..')
{
$lista[$file]["fechac"] = filectime($ruta.$file);
$lista[$file]["fecham"] = fileatime($ruta.$file);
$lista[$file]["passw"] = rand(1000,9999);
}
}
}
closedir($carpeta);
Código PHP:
foreach($lista as $var => $k)
echo "$var ===> fecha de creacion: ".@date('H:i:s d/m/Y',$k[fechac])." - fecha de modificacion: ".@date('H:i:s d/m/Y',$k[fecham])." - password: $k[passw]<br>";
Código HTML:
Notice: Use of undefined constant fechac - assumed 'fechac'
Al hacer var_dump($lista) me devuelve esto:
Código HTML:
array 'cartas' => array 'fechac' => int 1309168130 'fecham' => int 1309416302 'passw' => int 9107 'clientes' => array 'fechac' => int 1309168144 'fecham' => int 1309186634 'passw' => int 3902 'comercial' => array 'fechac' => int 1309343301 'fecham' => int 1309343344 'passw' => int 1162 'contratos' => array 'fechac' => int 1309285599 'fecham' => int 1309285599 'passw' => int 8835 'facturas' => array 'fechac' => int 1309290607 'fecham' => int 1309342440 'passw' => int 9190 'proformas' => array 'fechac' => int 1309194550 'fecham' => int 1309194550 'passw' => int 2196 'proveedores' => array 'fechac' => int 1309194550 'fecham' => int 1309194550 'passw' => int 9251