PHP strcspn Function

What is strcspn Function?

Explanation

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

Syntax:


strcspn(string1,string2,start,length)

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 :


<?php
echo strcspn("Hiox India!","I");
?>
Result :

5

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