<?php
function backStrpos($str, $needle, $offset){
$needler = backStr($needle);
$strr = backStr($str);
$offsetr = strlen($str) - 1 - $offset;
$posr = mb_stripos($strr, $needler, $offsetr);
return strlen($str) - 1 - $posr - strlen($needle);
}
function backStr($str){
$str = str_replace(array('<', '>'), array('>', '<'), $str);
return strrev($str);
}
function backStrpos($str, $needle, $offset){
$needler = backStr($needle);
$strr = backStr($str);
$offsetr = strlen($str) - 1 - $offset;
$posr = mb_stripos($strr, $needler, $offsetr);
return strlen($str) - 1 - $posr - strlen($needle);
}
function backStr($str){
$str = str_replace(array('<', '>'), array('>', '<'), $str);
return strrev($str);
}
$test = '<table><TR>TEXT</TR><TR>TEST</TR></table>';
$pos = mb_stripos($test, 'TEST', 0);
var_dump($pos);
var_dump(backStrpos($test, '<tr', $pos));
var_dump(backStrpos($test, '<tr', backStrpos($test, '<tr', $pos)));
------->
int(24)
int(19)
int(6)