$position=strripos("Welcome to plus2et.com",'M');
echo $position; // Optput is 21
echo strripos("Welcome to plus2et.com",'CO'); // Output is 19
$int_position=strripos(Main_string, Search_string,[optional: offset =0 ]);
Main_string : The string inside of which the search_string will be searched. echo strripos("Welcome to plus2et.com",'E'); // Output is 16
echo strripos("Welcome to plus2et.com",'E',3); // Output is 16
echo strripos("Welcome to plus2et.com",'C',-1); // Output is 19
echo strripos("Welcome to plus2et.com",'C',-4); // Output is 3
echo strripos("Welcome to plus2et.com",'O',-1); // Output is 20
echo strripos("Welcome to plus2et.com",'O',-4); // Output is 9
echo strripos("Welcome to plus2et.com",'E',-4); // Output is 16
echo strripos("Welcome to plus2et.com",'E',-7); // Output is 6
$position=strripos("Welcome",'z');
if($position==false){
echo " Not found ";
}else{
echo " Found and postion = ".$position;
}
// Output is Not found
Using the same code we will search for string W
$position=strripos("Welcome",'w');
if($position==false){
echo " Not found ";
}else{
echo " Found and postion = ".$position;
}
// Output is Not found
The search string is already present at position 0 . Above code need to change like this to get correct output.
$position=strripos("Welcome",'w');
if($position===false){
echo " Not found ";
}else{
echo " Found and postion = ".$position;
} // Output is Found and postion = 0
$position=strripos("Welcome",'M');
if($position===false){
echo " Not found ";
}else{
echo " Found and postion = ".$position;
} // Found and postion = 5
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.