PHP 8.4.24 Released!

Voting

: six minus one?
(Example: nine)

The Note You're Voting On

marvin_elia at web dot de
8 years ago
Find position of nth occurrence of a string:

    function strpos_occurrence(string $string, string $needle, int $occurrence, int $offset = null) {
        if((0 < $occurrence) && ($length = strlen($needle))) {
            do {
            } while ((false !== $offset = strpos($string, $needle, $offset)) && --$occurrence && ($offset += $length));
            return $offset;
        }
        return false;
    }

<< Back to user notes page

To Top