Example 1 — Find the Last Match
Find where the second "Hello" begins.
<?php
$text = "Hello World Hello";
$pos = strrpos($text, "Hello");
echo $pos, PHP_EOL; How It Works
- The text has "Hello" at index 0 and again later.
- strrpos searches from the end.
- It finds the second "Hello" first.
- That one starts at index 12.

