PHP 8.4.24 Released!

Voting

: max(six, eight)?
(Example: nine)

The Note You're Voting On

Daniel Brinca
18 years ago
Here is a simple function to find the position of the next occurrence of needle in haystack, but searching backwards  (lastIndexOf type function):

//search backwards for needle in haystack, and return its position
function rstrpos ($haystack, $needle, $offset){
    $size = strlen ($haystack);
    $pos = strpos (strrev($haystack), $needle, $size - $offset);
    
    if ($pos === false)
        return false;
    
    return $size - $pos;
}

Note: supports full strings as needle

<< Back to user notes page

To Top