How to Check If a String Contains a Specific Word in PHP?

In this post we will show you php contain, hear for php contains array we will give you demo and example for implement.

Throughout, In this tutorial you’ll learn php strpos case-insensitive.This article goes in detailed on implementing php string contains character.If you want to learn string contains php. So, from this post, you can find step by step process of doing php substr.


How to check if string contains substring in PHP?

There are the Following The simple About php strpos Full Information With Example and source code.

Read Also:  php check if string contains exist or not

As I will cover this Post with live Working example to develop php replace string

Example 1

<?php
$str = 'This is Main String';
 
if (strpos($str, 'This') !== false) {
    echo 'true';
}
//Output: true

Example 2

main string $str doesn’t contains the substring ‘Welcome‘ in it.

<?php
$str = 'This is Main String';
$substr = "Welcome";
 
if (strpos($str, $substr) !== false) {
    echo 'true';
}
?>
//Output: none

Example 3

check if a String contains a substring at start.

<?php
$str = 'This is Main String';
 
if (strpos($str, 'This') === 0 ) {
    echo 'true';
}
?>
//Output: true

Web Programming Tutorials Example with Demo

I hope you get an idea about php strpos case-insensitive.
I would like to have feedback on my pakainfo.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.