Current location: Hot Scripts Forums » Programming Languages » PHP » readdir() Function Help


readdir() Function Help

Reply
  #1 (permalink)  
Old 08-19-07, 12:29 AM
GHOwner GHOwner is offline
New Member
 
Join Date: Aug 2007
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
readdir() Function Help

Hello,

I'm currently tryign to create a function in my script that reads all the .flv files in a specific directory and then list the top 5 recent additions (newest uploaded) OR just have 5 random files appear that are in the directory.

It would list only the filenames, and thus not show the .flv at the end. Also, for each of them, I'd need it to display like this:
Code:
<li><a href="/somefile.php?file=+filename+">+filename+</a></li>
"+filename+" would be replaces with the name of the flv file (without extension) and would loop to display the top 5 newest (recently uploaded/changed) files.

Thanks in advance (I don't have a code ot show).
Reply With Quote
  #2 (permalink)  
Old 08-19-07, 04:08 AM
Nico's Avatar
Nico Nico is offline
Community Leader
 
Join Date: Sep 2005
Location: Spain
Posts: 8,075
Thanks: 11
Thanked 88 Times in 83 Posts
PHP Code:

$path 'files/';

$files glob("{$path}{*.flv,*.FLV}"GLOB_BRACE);
$times array_map('filectime'$files);

array_multisort($timesSORT_NUMERICSORT_DESC$files);
array_splice($files5);
unset(
$times);

echo 
'<ul>';

foreach (
$files AS $file)
{
  echo 
'<li><a href="/somefile.php?file='rawurldecode($file) .'">'basename($file'.'end(explode('.'$file))) .'</a></li>'"\n";
}

echo 
'</ul>'
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Parsing XML dodotopia PHP 1 02-08-06 03:51 PM
ASP upload prob minority ASP 1 06-27-05 08:35 AM
PHP Error Fairnie PHP 8 06-26-04 07:15 AM
Disable form fields to be submitted RickyRod JavaScript 2 05-24-04 10:15 AM
Help trim code down TheLaughingBandit JavaScript 0 09-02-03 09:50 AM


All times are GMT -5. The time now is 06:08 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.