Print the number of characters found in "Hello world!" before the character "w" in PHP

Description

The following code shows how to print the number of characters found in "Hello world!" before the character "w".

Example


  //w  w w.  j  av  a  2  s .  c o  m
<?php
    echo strcspn("Hello world!","w",0,6); 
    // The start position is 0 and the length of the search string is 6.
?>

The code above generates the following result.





















Home »
  PHP Tutorial »
    Data Types »




Array
Array Associative
Array Util
ArrayObject
Data Types
Date
Date Format
DateTime
Number
String
String Escape
String Filter
String HTML
String Type
Timezone