英[strɪŋ] 美[strɪŋ]

n.String; rope, belt; thread, plant fiber; [Computer Science] String

vt. Winding, tuning; To line up in a line or a series; to tie, tie or hang with a thread; to extend or extend

Third person singular: strings Plural: strings Present participle: stringing Past tense: strung Past participle: strung

php strcspn() function syntax

Function:Output the number of characters to search before finding a character in the string

Syntax: strcspn(string,char,start,length)

Parameters:

##ParametersDescription stringRequired. Specifies the string to search for. char Required. Specifies the characters to search for. startOptional. Specifies where in the string to start searching. length Optional. Specifies the length of the string (how many characters to search for).

Description: Returns the number of characters (including spaces) found in the string before any specified characters are found.

php strcspn() function example

<?php
echo strcspn("Hello php.cn!","p");
?>

Run instance»

Click the "Run instance" button to view the online instance

Output:

6


<?php
echo strcspn("PHP is a good development language! I love PHP","good");
?>

Run Instance»

Click the "Run Instance" button to view the online instance

Output:

9