Match for a word in a text with the PHP script

Gabriel Turqos

Active Member
Joined
Mar 11, 2019
Messages
17
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?
 

Use regex
such as
\b(?i)word\b would match the word 'word' and ignore case and the \b's are word boundaries.
 

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: How To Check If String Contains A Specific Word in PHP? – POFTUT
 

Solution
Back
Top