Jump to content

how to search a dir and display a txt file with php ???


thyscorpion

Recommended Posts

hi ???
i have a site in which i want the php code to search a specified dir on my site containing TXT files. The search will be with a search string i give.
i have been till now picking up txt files when i know a file name. but dont know how to search for a file according to a given keyword (or a part of keyword).
Please help me out as soon as possible. as i need the site up and running in 2 days. :-S.
was using something like this:
[code]$filename ="downloadedMovies.txt";   

$myFile = fopen($filename, "r"); //open the file for reading, file pointer will be at the beginning of the file
[/code]
but now i want to use a simple Include command. :-)..
hope someone can help me at the earliest..
dont worry i can do the codding myself but need to know how.. dont know the syntax and all.. :-)

thanks...
:)
Link to comment
Share on other sites

Thanks a ton!..  :-)..
ok one more Question. hope i am not bugging you thou....
like in some cases i have say three text files with the same keyword say : alpha_1.txt alpha_2.txt and alpha_3.txt and the keyword being 'alpha'.
i needed a way to pick up anyone of the three txt files in random. ???

thank you for your quick replies.. 
Link to comment
Share on other sites

[quote author=ryanlwh link=topic=101731.msg402866#msg402866 date=1153774816]
you can put all the results into an array, then use array_rand to randomly select a record.
[/quote]
hi thanks..
i needed something like:
if the keyword is: "manic monday"
the script should search for a "manic-monday.txt" and if not found ( no exact matches) . it should get teh next best match example: "manic.txt".
i agree putting them into the array is the right step forward but how to search in this way?

please help me out on this...
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.