Today, We want to share with you php string contains.In this post we will show you
php string contains case-insensitive, hear for PHP substring we will give you demo and example for implement.In this post, we will learn about How to Check If String Contains a Substring in PHP? with an example.
php string contains
Contents
Example : 1 Use the PHP strpos() Function
Check If a String Contains a Specific Word in PHP
<?php $word = "website"; $dumMarketing = "The quick free download website as well as full source code over article"; // Test if string contains the word if(strpos($dumMarketing, $word) !== false){ echo "Word Found!"; } else{ echo "Word Not Found!"; } ?>
Example : 2
<?php $market = 'This is Best Article Website'; if (strpos($market, 'This') !== false) { echo 'true'; } ?>
Example : 3
<?php $market = 'This is Best Article Website'; $substr = "Welcome"; if (strpos($market, $substr) !== false) { echo 'true'; } ?>
I hope you get an idea about php string contains.
I would like to have feedback on my infinityknow.com.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, donโt forget to share.
I am Jaydeep Gondaliya , a software engineer, the founder and the person running Pakainfo. I’m a full-stack developer, entrepreneur and owner of Pakainfo.com. I live in India and I love to write tutorials and tips that can help to other artisan, a Passionate Blogger, who love to share the informative content on PHP, JavaScript, jQuery, Laravel, CodeIgniter, VueJS, AngularJS and Bootstrap from the early stage.