$a = "this is school of sachin";
$pattern = "sch";
I want to get the position of the pattern matched from the end. For example in this case, sch
matches school
-- so the position of the pattern should be 3, i.e. from the end:
as mentioned below the index for the word school are arranged in this manner,so if the match of sch
is successful than the position from the end of the word which is getting matched(school) and to the start of the pattern(from the end) should be returned.
s c h o o l
5 4 3 2 1 0
^---^
matched pattern.
I have tried strpos()
but could not make it to serve my purpose.
echo strpos($a, $pattern); // this is wrong
The output of strpos() should be 3 according to my question.