Hello Guys,

Can anyone help me regarding this search engine I want to implement on my script?
Let's say i have 5 files (file11.txt, file12.txt, file13.txt, file14.txt and file15.txt) on my folder named FILES. Now i want to write script that when i search for a particular words, it will search all the 5 .txt files and display the particular file where the searched word appear.

For example, file1.txt and file2.txt contain a words "hello world", but file3 - file5.txt does not have that word. So when i search for the word "hello world", the script should tell that file1.txt and file2.txt contains the word "hello world".

Please guys. I will really appreciate any help regarding this. Thanks so much.

Do you want to write it all in PHP? See glob, file-get_contents, str_replace or preg_match in the manual to get started.

The lazy way would be to execute grep (if you have it) and let that return the results.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.