Contact Us Forum Rules Search Archive
WebProWorld Part of WebProNews.com
Page One Link To Us Edit Profile Private Messages Archives FAQ RSS Feeds  
 

Go Back   WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum
Subscribe to the Newsletter FREE!


Register FAQ Members List Calendar Arcade Chatbox Mark Forums Read

Web Programming Discussion Forum Working with an API? Developing a plugin? Writing a Mod or script for your favorite blog, Web 2.0 site or Forum? Welcome.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-24-2008, 11:45 AM
WebProWorld New Member
 

Join Date: May 2008
Posts: 11
punkrazio RepRank 0
Default order file by last mod

Hi all
i've got a directory where php creates a txt file every time someone update his stock.

i create file txt like this:

customer-last-update-stock-05-06-2008---10-29-42.txt

i read the files in the directory with this script:

PHP Code:
if ($handle opendir('/web/htdocs/directory/home/customer/update_stock/')) {
    while (
false !== ($file readdir($handle))) { 
        if (
$file != "." && $file != "..") { 
            echo 
"<a href=\"../customer/update_stock/$file\" target=\"_blank\">$file</a><br>\n"
        } 
    }
    
closedir($handle); 

now my question is..

how can i order and print the files by last mod time??
there is any way?

hope you can help

bye bye
Reply With Quote
  #2 (permalink)  
Old 07-24-2008, 02:55 PM
WebProWorld New Member
 

Join Date: Oct 2005
Posts: 18
wdillsmith RepRank 0
Default Re: order file by last mod

use 'ls -t' or 'ls -tr'
__________________
Looking for a unique gift? Send one of our gourmet cookie bouquets today.
Food lovers - visit the Gourmet Gift of the Day Blog for delicious ideas.
Reply With Quote
  #3 (permalink)  
Old 07-24-2008, 06:26 PM
DaveSawers's Avatar
WebProWorld Veteran
 

Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 389
DaveSawers RepRank 1
Default Re: order file by last mod

Yuk! Why not put this sort of stuff on a small database table?
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
  #4 (permalink)  
Old 07-25-2008, 11:11 AM
WebProWorld New Member
 

Join Date: May 2008
Posts: 11
punkrazio RepRank 0
Default Re: order file by last mod

its useless put everything so small in a database
anyway i have found the solution for every one who need it:

$arrayfile = Array();
function ordina($file1,$file2)
{
$tempo1 = filectime($file1);
$tempo2 = filectime($file2);
return ($tempo1 < $tempo2) ? 1 : -1;
}
if ($handle = opendir('/web/htdocs/domain/home/customer/update_stock/'))
{
while (false !== ($file = readdir($handle)))
{
if ($file != "." && $file != "..") {
$arrayfile[]='../customer/update_stock/'.$file;
}
}
closedir($handle);
usort($arrayfile,'ordina');
//print_r($arrayfile);
foreach($arrayfile as $txt)
{
echo "<a href=\"$txt\" target=\"_blank\">".str_replace("../customer/update_stock/","",$txt)."</a><br>\n";
}
}
clearstatcache();
Reply With Quote
  #5 (permalink)  
Old 07-25-2008, 04:54 PM
DaveSawers's Avatar
WebProWorld Veteran
 

Join Date: Dec 2006
Location: Calgary, Alberta, Canada
Posts: 389
DaveSawers RepRank 1
Default Re: order file by last mod

Quote:
Originally Posted by punkrazio View Post
its useless put everything so small in a database
I guess we'll just have to agree to disagree on that one.
__________________
Dynamic Software Development
www.activeminds.ca
Reply With Quote
Reply

  WebProWorld > Webmaster, IT and Security Discussion > Web Programming Discussion Forum


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

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

Similar Threads
Thread Thread Starter Forum Replies Last Post
File Extension / File Suffix in SEO Ladana Search Engine Optimization Forum 6 07-10-2008 06:56 PM
html file w/ no file extension kruser Web Programming Discussion Forum 10 02-16-2008 01:04 AM
How to converter video file into a flash file ,with effect? andy_lucky Flash Discussion Forum 0 04-04-2006 12:37 PM
Windows 2000 Slow with File Open and File Save Dialog Boxes steve0 IT Discussion Forum 2 09-15-2005 06:27 PM
Dreamweaver: Error accessing file...bad file path mimsymc Graphics & Design Discussion Forum 6 07-10-2005 09:43 PM


Search Engine Optimization by vBSEO 3.2.0