I need to limit the amount of files that will be displayed in a given directory.
This is my code in php that lists the files in my directory:
<?php
$diretorio = getcwd(). "/arquivos" ;
$ponteiro = opendir($diretorio);
while ($nome_itens = readdir($ponteiro))
$itens[] = $nome_itens;
sort ($itens);
foreach ( $itens as $listar )
if ( $listar!="." && $listar!="..")
print '.$listar.';
?>
Is there any way to increment this code so that it displays only the last 5 files uploaded to this directory?