Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

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

The Note You're Voting On

patrick at hexane dot org
17 years ago
I wonder why there isn't a mb_str_replace(). Here's one for now:

function mb_str_replace( $needle, $replacement, $haystack ) {
$needle_len = mb_strlen($needle);
$pos = mb_strpos( $haystack, $needle);
while (!($pos ===false)) {
$front = mb_substr( $haystack, 0, $pos );
$back = mb_substr( $haystack, $pos + $needle_len);
$haystack = $front.$replacement.$back;
$pos = mb_strpos( $haystack, $needle);
}
return $haystack;
}

<< Back to user notes page

To Top