PHP Coding
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPHP Coding

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old August 22nd, 2002, 06:42 AM
Anonymous Anonymous is offline
Registered User
Codewalkers God 35th Plane (22000 - 22499 posts)
 
Join Date: Apr 2007
Posts: 22,309 Anonymous User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 24
Indexing text files in a folder

I'm newbie on Php. I cannot write codes but only modify.
I need a code doing this:
I'll put text files in a folder like file1.txt,file2.txt ...
I want to search this files, list most recent 10 and if files

call, script will put into the site design with <pre> tags.
I hope I can explain what I need.
I dont know Php is suitable for that.
Please help me about this.
Thanks.

Reply With Quote
  #2  
Old August 22nd, 2002, 03:58 PM
Gipz Gipz is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Stockholm, Sweden
Posts: 98 Gipz User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to Gipz
RE: Indexing text files in a folder


Php can do what you want. Right now I haven't the time to code the function but I'm sure some other happy soul here at codewalkers.com will...

Reply With Quote
  #3  
Old August 22nd, 2002, 06:23 PM
notepad notepad is offline
Codewalkers Loyal (3000 - 3499 posts)
 
Join Date: Apr 2007
Location: Central, IL USA
Posts: 3,214 notepad User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 5
Send a message via AIM to notepad
RE: Indexing text files in a folder

not sure what you mean when you say "if files call" but as for the rest..

you'll read a dir, store the contents of the dir into an array. using your naming convention (file1, file2 etc..) you'll probably want to run a natsort function on your array. then run a recursive function on your array to search the last 10 (most recent) files stored from the dir.. or just compare last-modified times to determin the most recent that way.. hope that makes sense.

um.. i could come up with an example if you need one. the php.net manual should help you get started though

Reply With Quote
  #4  
Old August 23rd, 2002, 09:58 AM
Mustafa Karaoglu Mustafa Karaoglu is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Location: Adana - Turkey
Posts: 39 Mustafa Karaoglu User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 2
Send a message via ICQ to Mustafa Karaoglu Send a message via AIM to Mustafa Karaoglu Send a message via Yahoo to Mustafa Karaoglu
RE: Indexing text files in a folder

you can use something like this I think. Fix it according to your needs.

to call the function add this line to your php page
directory(your/files/parh);


function directory($result)
{
$handle=opendir("$result");

GLOBAL $icerik;
$count = 0;

# Gather the files, and put them in a array
while( $file = readdir( $handle) )
{
$file_array[] = $file;
}
foreach( $file_array as $file )
{
if( $file == ".." || $file == "." )
{
continue;
}
if( !eregi( ".txt$", $file ) )
{


continue;
}
$file=eregi_replace(".txt$",".txt",$file);
# Display the file with a link

echo"<A href="index.php?variables_to_call_file">$file</A> || ";

# Count the file that was displayed
$count++;
}
echo"";
#close thedirectory you used
closedir($handle);


# Display Number of files that were displayed
echo"<P> There are <b>$count</b> tests in this section";


return $result;

}



Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPHP Coding > Indexing text files in a folder


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway