CKTIS / PHP
strrpos()
Return the last byte position of a case-sensitive literal match, or false if absent.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
strrpos(string $haystack, string $needle, int $offset = 0): int|falseReturn the last byte position of a case-sensitive literal match, or false if absent. A positive offset restricts starts from below, and a negative offset bounds the last candidate start from the end. A returned position of zero is a valid hit.
Signature
strrpos(string $haystack, string $needle, int $offset = 0): int|false
Example output
[4,0,false,0]
Examples
<?php
$s="aba-aba"; echo json_encode([strrpos($s,"aba"),strrpos($s,"aba",-4),strrpos($s,"ABA"),strrpos("one","o")]);
Result
[4,0,false,0]