- 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
substr_count() function in PHP
The substr_count() function is used to count the number of sub-strings.
Syntax
substr_count(str,substr,begin,len)
Parameters
str − The string to check
substr − The string to search for
begin − Where to begin searching in the string
len − The length of the search
Return
The substr_count() function returns the number of times substring occurs in the string.
Example
The following is an example −
<?php $str = 'This is our example!'; echo strlen($str); echo "
"; echo substr_count($str, 'our'); ?>
Output
20 1
Advertisements