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
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.