strcspn & strspn
strcspn
strcspn
- It find the length of initial segment of a string1 not matching mask
Syntax:
int strcspn ( string str1, string str2)
It returns the length of the initial segment of str1 which does not contain any of the characters in str2.
strspn
strspn
- It find the length of initial segment of a string matching mask
Syntax:
int strspn ( string str1, string str2)
- It returns the length of the initial segment of str1 which consists entirely of characters in str2.
Example:
echo $res = strcspn(”hello”,”by”);
Now it returns the length 5.
echo $res = strspn(”hello”,”oleh”);
Now it returns the length 5.
