what is the syntax of the STRCSPN() function in php?
strcspn(string,char,start,length)
Parameter | Description |
---|---|
string | Required. Specifies the string to search |
char | Required. Specifies the characters to search for |
start | Optional. Specifies where in string to start |
length | Optional. Specifies the length of the string (how much of the string to search) |
examples of the STRCSPN() function in php
Example 1. In this example, we print the number of characters found in “Hello world!” before the character “w”.
<?php
echo strcspn("Hello world!","w");
?>
Example 2. In this example, we use all parameters to print the number of characters found in “Hello world!” before the character “w”.
<?php
echo strcspn("Hello world!","w",0,6); // The start position is 0 and the length of the search string is 6.
?>