strcspn & strspn

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.

Leave a Reply

You must be logged in to post a comment.


All material @ copyrighted by chrisranjana.com. If you want to link to this article you are welcome to do so. Unauthorized publication is strictly prohibited. This developer tutorial website contains articles by Php programmers , Software developers, Mysql programmers and asp c# programmers. This website also contains ajax tutorials and advanced mysql sql stored procedures and functions tutorials and sample codes.