Monday 29 September 2014

strspn in PHP

PHP strspn() function is utilized to get the amount of characters that considered in the principle string that holds only characters from character listed in the second string.

Syntax:

strspn(string,charlist,start,length)
string : Required. Defines the input string to search

charlist : Required. Defines the characters to search for

start : Optional. Defines where in string to start

length : Optional. Defines the length of the string (how much of the string to search).

Note : This function is binary safe.

Example:

<?php
echo strspn("Good Morning","crnMiu");
?>
Output will be:
5

0 comments:

Post a Comment