PHP strstr Function



PHP Tutorial > String Functions > strstr Function

The strstr function in PHP is used to return all characters of a string after the first match. The syntax of the strstr function is:

strstr ('string', 'match_pattern', [before_indicator])

If the optional before_indicator parameter is set to TRUE, the strstr function returns all characters of a string before the first match. before_indicator is introduced in PHP 5.3.0.

Let's take a look at the examples below:

Example 1

print strstr ('PHP strstr function','str');

Result:

strstr function

Example 2

print strstr('PHP strstr function','str', TRUE);

Result:

PHP

Next: PHP substr Function

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.




More 1Keydata Tutorials



PHP addslashes
PHP echo
PHP explode
PHP htmlentities
PHP htmlspecialchars
PHP implode
PHP md5
PHP number_format
PHP print
PHP str_replace
PHP strlen
PHP strpos
PHP strstr
PHP substr
PHP trim

PHP Syntax

PHP Sitemap

PHP Resources