strstr in php

Today, We want to share with you strstr in php.In this post we will show you php string contains, hear for explode in php we will give you demo and example for implement.In this post, we will learn about How to String Replace in PHP Functions? with an example.

Free Live Chat for Any Issue

php string functions

In this tutorial we learn to all about strstr in php Examples like as a stristr in php, strpos in php, str_replace php, strchr in php, explode in php, php string contains, php string functions or many more.

Also Read This 👉   Laravel MySQL Advanced Query Techniques with Example

The strstr() PHP function is help to get the first occurrence of a data string.

PHP strstr() Function

<?php
echo strstr("Hello world!","world");
?>

pass an integer as $search

<?php
$user_str_data = "Pakainfo";
echo strstr($user_str_data, 101);
?>

Examples of strstr()

<?php   
    $user_str_data = "Welcome to Pakainfo";  
    $quick_setting = "e";  
    echo strstr($user_str_data, $quick_setting);  
      
    echo '</br>';  
    $quick_setting_new = "JAVA";          //case-sensitive  
    var_dump(strstr($user_str_data, $quick_setting_new));  
      
    echo '</br>';  
    var_dump(strstr($user_str_data, "WeLcOmE"));  
?>  

Example 2

<?php   
$user_str_data = "Welcome to Pakainfo website.";  
    $before_search = true;  
    $quick_setting = "a";   
    echo strstr($user_str_data, $quick_setting, $before_search);  
      
    echo '</br>';  
    $quick_setting_new = "E";  
    var_dump(strstr($user_str_data, $quick_setting_new, $before_search));  
      
    echo '</br>';  
    $search3 = "nt";  
    echo strstr($user_str_data, $search3, $before_search);  
?>  

Example 3

<?php   
    echo strstr("There are seven Websites(pakainfo, 4cgandhi,infinityknow) in the world.", 119, true);      
    echo '</br>';  
       
    var_dump(strstr("There are seven Websites(pakainfo, 4cgandhi,infinityknow) in the world.", 84));        
    echo '</br>';   
    var_dump(strstr("There are seven Websites(pakainfo, 4cgandhi,infinityknow) in the world.", 79));    
?>    

I hope you get an idea about strstr in php.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.