Find the Index of Last Occurrence of a Substring in a String using PHP

strrpos function

<?php

$text = '123 456 56 78';
$idx = strrpos($text, '56');

echo $idx; // 8

Leave a Comment

Cancel reply

Your email address will not be published.