Should be pretty straight-forward with something like what themarty suggested. Where it can get kind of "messy" is if you search for "play", for instance, and whether or not you want to find "plays", "played", and "playing" yet might not want to match on "playbill".
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
my php knowledge is basic so could you expand more, thanks
It's not so much a question of PHP knowledge (at this point) as it is deciding what your exact functional requirements are. Do you only want to match exact words, or do you want to match if the search word is contained within a larger word -- or something more complex such as matching only with certain suffixes such as "s", "es", "er", "ed" or "ing"? Should the searching be case-insensitive? Is there some other requirement I haven't thought of?
Once you nail down the exact functional requirements, it's then much easier to come up with an exact coding solution.
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
I would only like to find exact words. The reason i want to find exact words is because i have a download counter that outputs into a .txt document and i would like to display how many times something has been downloaded.
Eg. say i have a file called example.zip every time somebody downloads it it adds a line to the txt file saying: example.zip and the date.
so i wanted to see how many times it says example so i can say how many times its been downloaded.
If you can make a database connection is would be much wiser to store this information there instead of a text-file.
also be careful with your concept of words. if someone downloads example.zip and example.txt (or even Example.zip) you probably don't want to count them as hits belonging to one and the same file
I would only like to find exact words. The reason i want to find exact words is because i have a download counter that outputs into a .txt document and i would like to display how many times something has been downloaded.
Eg. say i have a file called example.zip every time somebody downloads it it adds a line to the txt file saying: example.zip and the date.
so i wanted to see how many times it says example so i can say how many times its been downloaded.
themarty's solution in the first reply should do the job then. (Remove the "i" after the final "/" of the regular expression if you want the matching to be case-sensitive.)
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in Nation
If you can make a database connection is would be much wiser to store this information there instead of a text-file.
also be careful with your concept of words. if someone downloads example.zip and example.txt (or even Example.zip) you probably don't want to count them as hits belonging to one and the same file
I did what you said and made a db connection and just out putted the data that way.
Bookmarks