Searching stuff.
Author |
Message |
Apage43
|
Posted: Fri Nov 28, 2003 12:45 pm Post subject: Searching stuff. |
|
|
I want to search a text file for a string. Like a search engine, and want to get the line numbers of all matching lines, what would be the best way to do that? I've used grep to do it, but I think that makes my script OS dependent. |
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Blade
|
Posted: Mon Dec 01, 2003 3:23 pm Post subject: (No subject) |
|
|
whatif you read each line into an array then search the array for the file and record the element number each word is in? |
|
|
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Mon Dec 01, 2003 10:31 pm Post subject: (No subject) |
|
|
or make up a function like i made for turing called wordseparator or something that separates the works by space or any other separators... so u can search yer string for words or even sentences.... |
|
|
|
|
![](images/spacer.gif) |
Blade
|
Posted: Tue Dec 02, 2003 12:24 pm Post subject: (No subject) |
|
|
or you can use a function called explode()
goto http://php.net |
|
|
|
|
![](images/spacer.gif) |
|
|