Voting

: six plus one?
(Example: nine)

The Note You're Voting On

marvin_elia at web dot de
7 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