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.

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.

Read Also:  How to String Replace in PHP Functions?

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.

Read Also:  PHP Create zip archive and Download Zip File using ZipArchive

Related FAQ

Here are some more FAQ related to this Article:

  1. Read Also:  Laravel delete foreign key Constraint Using Migration
  2. Read Also:  laravel 6 Update Data in AJAX CRUD Operations
  3. Read Also:  Laravel 6 Update Query using Eloquent Example
  4. Read Also:  Disable Crontab Email Notifications suppress cron
  5. Read Also:  SQL GROUP BY and HAVING Clause with Examples
  6. Read Also:  PHP Shorten String Function
  7. Read Also:  PHP String Explode and Implode Function
  8. Read Also:  PHP Multi languageSupport To Website Management
  9. Read Also:  how to compare two strings in PHP if condition?
  10. Read Also:  Laravel 6 get Session ID Easily