strspn() function in PHP


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

Samual Sam
Samual Sam

Learning faster. Every day.

Updated on: 26-Dec-2019

42 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements