strspn() function in PHP

PHPProgrammingServer Side Programming

The strspn() function returns number of characters found in the string from the charlist parameter.

Syntax

strspn(str,charlist,begin,len)

Parameters

  • str − The string to search

  • charlist − The characters to find

  • begin − Where to begin in the string

  • len − Length of the string

Return

The strspn() function returns number of characters found in the string from the charlist parameter. It returns false if string is not found.

Example

The following is an example −

 Live Demo

<?php
   echo strspn("mobilephone","o");
?>

Output

The following is the output −

0
raja
Published on 17-Oct-2018 13:04:13
Advertisements