strstr() function in PHP

王林
Release: 2023-09-08 11:56:01
forward
1617 people have browsed it

strstr() function in PHP

strstr() function is used to find the first occurrence of a string.

Note - This function is case-sensitive.

grammar

strstr(str,search,before)
Copy after login

parameter

  • str - The string to search for

  • search - The string to search for

  • before - A boolean value, default value is "false". If set to "true", returns the portion of the string preceding the first occurrence of the search parameter.

return

strstr() function returns the rest of the string, or false if the string is not found.

Example

The following is an example -

Live Demo

<?php 
   echo strstr("Brad Pitt!", "a");
?>
Copy after login

Output

ad Pitt!
Copy after login

Example

The following is an example -

Live Demo

<?php 
   echo strstr("Brad Pitt!", "a", true);
?>
Copy after login

Output

Br
Copy after login

The above is the detailed content of strstr() function in PHP. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:tutorialspoint.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!