Match for a word in a text with the PHP script

Gabriel9999

Member
Joined
Mar 12, 2019
Messages
38
Reaction score
4
Credits
130
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?
 


captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,531
Reaction score
1,672
Credits
15,089
should we have a dev php using linux sub forum ?

to simply confirm that a word exists but you don't want to do anything with it ; for instance maybe you want to run through a text string that was submitted POST from a contact form to check for spam then you can also use :

strpos($inputString, $keyword)

where $keyword is an array of key words

and something like :

foreach($this->keywords as $keyword)

{

if (strpos($inputString, $keyword) !== false) { do something }

}
 
Last edited:

ralph5WZ

New Member
Joined
May 2, 2020
Messages
9
Reaction score
3
Credits
70
captain-sensible, it's a nice solution, thanks for reminding. There are plenty of times, when I'm trying to implement features like that during simple stages of emr development and as you know, when you concentrate on some specific features and code parts - you can easily forget about other great techniques and code snippets.
 

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,531
Reaction score
1,672
Credits
15,089
Well once I had a reply from a guy called Stefan Mischook (k* php) in a conversation about rememebering concepts rather than exact code; he said : "i've forgotten more on code than i know now ! " thats always made me feel comfortable when i need to keep looking things up
 

captain-sensible

Well-Known Member
Joined
Jun 14, 2019
Messages
2,531
Reaction score
1,672
Credits
15,089
if you want to see code in action and have a laugh i will give you a link to a dev/daughter live web site where i'm writing a light c.m.s on top of CodeIgniter4
 
$100 Digital Ocean Credit
Get a free VM to test out Linux!

Members online


Top