$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 & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.