PHP strstr() Function


The strstr() function is used to find the first occurence of the string .This function is case-sensitive.

Syntax
strstr(string,search,before_search)
Parameters
  • String - (Required) Specify the string to search.
  • search - (Required) Specify the string to search .if this parameter is a number then return ASCII value.
  • before_search - (optional) it is false because defalut value.if it is returns true part of the string before the first occurrence of the search parameter.
Example
<?php
  echo strstr("Good Morning!","Morning")."<br>";
  echo strstr("Good Morning!","Morning",true)."<br>";
  echo strstr("Good morning!",100);
?>

Output

Morning!
Good
d morning!

Prev Next