what is the syntax of the STRSPN() function in php?
strspn(string,charlist,start,length)
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
charlist | Required. Specifies the characters to find |
start | Optional. Specifies where in the string to start |
length | Optional. Defines the length of the string |
examples of the STRSPN() function
Example 1. In this example, we return the number of characters found in the string “Hello world!” that contains the characters “kHlleo”.
<?php
echo strspn("Hello world!","kHlleo");
?>
Example 2. In this example, we return the number of characters found in the string “abcdefand” that contains the characters “abc”.
<?php
echo strspn("abcdefand","abc");
?>