How to get the position of character in a string in PHP ?
In this article, we will get the position of the character in the given string in PHP. String is a set of characters. We will get the position of the character in a string by using strpos() function.
strpos(string, character, start_pos)
- string (mandatory): This parameter refers to the original string in which we need to search the occurrence of the required string.
- character (mandatory): This parameter refers to the string that we need to search.
- start_pos (optional): Refers to the position of the string from where the search must begin.
Return Value: It returns the index position of the character.
Example 1: PHP Program to get the position of particular character in the given string.
12 0 2 5