PHP strcspn Function

What is strcspn Function?


In PHP this function returns the number of characters found in a string before any part of the specified characters are found.



In the above syntax "string1" is the string in which "string2" is searched for, "start" specifies where in the string to start,"length" specifies the length of the string to check for.

Example :

echo strcspn("Hiox India!","I");
Result :


In the above strcspn Function example the string "I" is checked to return the result "5" as it is found in "Hiox India!".

PHP Topics

Ask Questions

Ask Question