- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
stristr() function in PHP
The stristr() function is used to search for the first occurrence of a string inside another string.
Note − The function is case-insensitive
Syntax
stristr(str, search, before_search)
Parameters
str − The string to search in
search − The string to search for
before_search − 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 stristr() function returns the matched substring.
Example
The following is an example −
<?php $mystr = 'Tom Hanks!'; if(stristr($mystr, 'Tim') === FALSE) { echo 'Tim is not in the string!'; } ?>
Output
Tim is not in the string!
Example
The following is an example −
<?php echo stristr("Demo text!","TEXT",true); ?>
Output
Demo
Advertisements