Are you building a web application or just learning PHP and wanted to check if some strings on particular variable have the value that you are looking or not and then do something with it? Then you came at the right place.
Here we have posted simple and best most useful code snippets that will help you to check if a string contains a specific word in PHP or not.
Read Also: How to check if Array Contains a Specific Word in PHP
So let’s begin it.
How to check if a string contains a specific word in PHP
Below is the code that will check if a string contains a specific word or not and will about it. We used just the simple string and stored it in the variable. $text
Take a look at the code Snippet.
What we are checking above is only a simple “are” is available in the variable or not. $text
And we got the value true because the was the word$text
“are”.
That’s it guys hope this article was helpful for you and you have understood it clearly. Don’t forget to tell us how was it in the comment box and share this article if you love it.