PHP String Functions

strpos() Function

Definition and Usage

The strpos() function finds the position of the first occurrence of a string inside another string.

Note:
  • The strpos() function is case-sensitive.

  • Syntax

    strpos(string,find,start)


    Parameter Description
    string Required. Specifies the string to search
    find Required. Specifies the string to find
    start Optional. Specifies where to begin the search

    Example

    Find the position of the first occurrence of "php" inside the string:

    <?php
    echo strpos("I love php, I love php too!","php");
    ?>

    Run Example>>