PHP

PHP Menu

PHP

substr_count() Function - Definition, Syntax, Parameters, Examples

Definition

The substr_count() function is used to count the number of times a substring occurs in a string.

Syntax

substr_count(string, substring, start, length)

Parameters

Parameter Description
string Required. Specifies the string to check.
substring Required. Specifies the string to search for.
start Optional. Specifies where in string to start searching. If negative, it starts counting from the end of the string.
length Optional. Specifies the length of the search.

Example

<?php
echo substr_count("Welcome to the PHP tutorials. Learn PHP quickly.", "PHP");

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods