PHP strspn() Function


The strspn() function is used to returns the number of characters found in the string that contains only characters from the charlist parameter.

Syntax
strspn(string,charlist,start,length)
Parameters
  • string - (Required) Specify the string to search.
  • char - (Required)Specify the characters to find.
  • start - (optional)Specify where the string to start.
  • length -(optional) Specify the length of the to string.
Example
<?php
    echo strspn("Good Morning","MornGsd");
?>

Output

4
Example
<?php
    echo strspn("Good Morning !","Morning Good !");
?>

Output

14

Prev Next