$position=stripos("Welcome to plus2et.com",'CO');
echo $position; // Output is 3
$int_position=stripos(Main_string, Search_string,[optional: offset =0 ]);
Main_string : The string inside of which the search_string will be searched. $position=stripos("Welcome to plus2et.com",'CO',4);
echo $position; // Output is 19, not 3
$position=stripos("Welcome to plus2et.com",'y');
if($position==false){
echo " Not found ";
}else{
echo " Found and position = ".$position;
}
// Output is Not found
Using the same code we will search for sub-string W
$position=stripos("Welcome to plus2et.com",'W');
if($position==false){
echo " Not found ";
}else{
echo " Found and position = ".$position;
}
// Output is Not found
The search string ( W ) is already present at position 0 . Above code need to change like this to get correct output.
$position=stripos("Welcome to plus2et.com",'w');
if($position===false){
echo " Not found ";
}else{
echo " Found and position = ".$position;
} // Output is Found and position = 0
$position=stripos("Welcome to plus2et.com",'M');
if($position===false){
echo " Not found ";
}else{
echo " Found and position = ".$position;
} // Output is Found and position = 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.