Match for a word in a text with the PHP script

Gabriel9999

Member
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
Credits
5,719
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
Credits
62
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
Credits
5,719
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
Credits
5,719
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
 



Latest posts

Top