I have an applications developed with PHP. I have a big text file where I want to match for a word but this can be change in the feature. How can I match a word in PHP?
Is this where the word you want to match for changes? I'm not understanding the question.
Would need more details on what exactly you are trying to do. Just a True/False word is in text? I don't know about PHP, but python would be something like;
long_text = "This is the text that you are searching to find the specific text you want in this wordy string"
find_word = " word "
print(find_word in long_text)
That would return False because the word "word" does not exist in that string. Note that the find_word variable has spaces around the word. This prevents it from matching "wordy" If you left the spaces out it would match if it found those four characters in a row.
May I ask why PHP? Python seems to be the preferred language now which is why I am learning it.
-Otanx
There are different functions and ways to match a word in PHP. Best way is using preg_match() function. In the following example we will search the forum word in the $bigtext content.
preg_match('/forum/',$bigtext)
Look: https://www.networking-forums.com/programming-goodies-and-software-defined-networking/match-for-a-word-in-a-text-with-the-php-script