Asked 7 years ago
6 Apr 2017
Views 1401

posted

how to use strpos to find macth for string in PHP ?


strpos("hello world","hello")


is that strpos used properly ?

how to find match for given string in other string . how we find it , is it matched or not in strpos function in PHP ?
Rasi

Rasi
answered Nov 30 '-1 00:00

strpos had two sibling function strrpos() , stripos() , strripos()

strrpos() can be used to find last occurrence of string in given string .
stripos() can be used to find first occurrence of string in given string but its case-insensitive .
strripos() can be used to find last occurrence of string in given string but its case-insensitive .

Nilesh

Nilesh
answered Nov 30 '-1 00:00

strpos is very good function which most PHP developer use many time in their work


$pos = strpos("Hello world","world");


strpos will return false if second string argument not find in first string argument .
strpos will retrun the position of the first occurrence of a second string argument in a first string argument .
css-learner

css-learner
answered Jan 19 '22 00:00

strpos() function at php — Find the position of the first occurrence of a substring in a string



$me="i am coder";
$findme="coder";
    $pos = strpos($me,$findme);
    if($pos===false){
// not found
}else{ 
 // found do  code here
    }
Post Answer