<?PHP echo strrpos("The best time is no time at that time","time"); //33 if (strrpos("The best time is no time at that time","PHP")) { echo "contain PHP"; } else echo "do not contain PHP"; //do not contain PHP echo strrpos("The best time is no time at that time","The"); //0 ?>
<?PHP if (strrpos("The best time is no time at that time","TIME")) { echo "contain TIME"; } else echo "do not contain TIME"; //do not contain TIME if (strrpos("The best time is no time at that time","time")) { echo "contain time"; } else echo "do not contain time"; //contain time ?>
If the occurrence position is the 1st character position, will return 0. That may cause wrong results when used in a condition statement.
<?PHP if (strrpos("The best time is no time at that time","The")) { echo "contain The"; } else echo "do not contain The"; //do not contain The ?>
The correct statement is:
<?PHP if (strrpos("The best time is no time at that time","The") === FALSE) { echo "do not contain The"; } else echo "contain The"; //contain The ?>