BHForum
asked on
PHP Grep command help
Just beginning with PHP. I am trying to use a PHP page to run something similar to the following Linux command:
and to have it output to a web page just as the output of the grep command. Basically listing every line containing the search string.
grep "text string" filename
and to have it output to a web page just as the output of the grep command. Basically listing every line containing the search string.
ASKER
Thank you...will check that out
ASKER
Looking through these string commands, none seem to list all lines containing the string. They will find first, last, count, position, etc., but do not output showing all lines containing the string. For instance, if I had the following text file:
and I search for the string "words" the result should be:
Line of text containing words
This is the second line of text
This line also contains words
This is the fourth line of text
and I search for the string "words" the result should be:
Line of text containing words
This line also contains words
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
There are many functions to find the occurrence of a string.. strstr,strchr,etc... the way for doing it would differ based on the exact requirement