
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
strstr() function in PHP
The strstr() function is used to find the first occurrence of a string.
Note − The function is case-sensitive.
Syntax
strstr(str,search,before)
Parameters
str − The string to search
search − The string to search for
before − A boolean value whose default is "false". If set to "true", it returns the part of the string before the first occurrence of the search parameter.
Return
The strstr() function returns the rest of string or false if the string is not found.
Example
The following is an example −
<?php echo strstr("Brad Pitt!", "a"); ?>
Output
ad Pitt!
Example
The following is an example −
<?php echo strstr("Brad Pitt!", "a", true); ?>
Output
Br
- Related Articles
- strstr() function in C/C++
- What is strstr() Function in C language?
- strstr() in C++
- Implement strStr() in Python
- strcmp() function in PHP
- strcoll() function in PHP
- strcspn() function in PHP
- strip_tags() function in PHP
- stripcslashes() function in PHP
- stripos() function in PHP()
- stristr() function in PHP
- stripslashes() function in PHP
- strlen() function in PHP
- strnatcasecmp() function in PHP
- strnatcmp() function in PHP

Advertisements