PHP string function strcspn

The String function strcspn() is used to count the number of characters including white spaces in a string.

Syntax

Parameter Description
mystring This is the required parameter which specifies the string to search.
char This is the required parameter which specifies characters to search for in the string.
start This is an optional parameter which specifies  from where in the string to start searching.
length This is an optional parameter which specifies  length of the string.

Return Value

It will returns the length of the string before any part of the specified character.

Example

NOTE: This function is binary-safe