What PHP Function is used to find position of a string?
PHP strpos()
function is used to find the first occurrence of substring in the given string.
<?php
echo strpos("The color of apple is red.","apple");
?>
Tutorials Class - Output Window
13
The word 'apple'
is found at the position '13'
. Remember that the position of string/character start at 0
, and not 1
. This function is very useful to find certain patterns or words in a string.
Learn more about the similar topics:
Tutorials |
---|
No Content Found. |
Exercises & Assignments |
---|
No Content Found. |
Interview Questions & Answers |
---|
No Content Found. |