Searching for text in text file

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

ylkien
New php-forum User
New php-forum User
Posts: 28
Joined: Sat Dec 14, 2002 9:43 am

Searching for text in text file

Postby ylkien » Sat Sep 06, 2003 8:30 am

Hi,

i looked through the functions list, but i could find any function that could search something (like a phrase) in a text file. The closes i could get is fseek(), which isn't what i want. Could there be a function like "fsearch"?


thanks.

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Sat Sep 06, 2003 9:13 am

there are no such function....

try to use regular expresions for searching string in text file...

User avatar
Redcircle
Moderator
Moderator
Posts: 830
Joined: Tue Jan 21, 2003 10:42 pm
Location: Michigan USA
Contact:

Postby Redcircle » Sat Sep 06, 2003 10:44 am

you would need to read the file into php and use preg_match.

User avatar
swirlee
Moderator
Moderator
Posts: 2272
Joined: Sat Jul 05, 2003 1:18 pm
Location: A bunk in the back
Contact:

Postby swirlee » Sat Sep 06, 2003 11:30 pm

Redcircle wrote:you would need to read the file into php and use preg_match.


Or just strpos() for simple matching.

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

file

Postby ruturajv » Sun Sep 07, 2003 9:50 pm

use the file function get the text in the array and then use array functions to search the text :idea:


Return to “PHP coding => General”

Who is online

Users browsing this forum: Bing [Bot] and 3 guests