strcspn()

It returns the number of characters found in a string before any part of the specified characters are found.

Example

<?php
echo strcspn(“phpcode”,”c”);
?>

Output

3

Share