1 <?php
2 /**
3 * @package utf8
4 */
5
6 //---------------------------------------------------------------
7 /**
8 * UTF-8 aware substr_replace.
9 * Note: requires utf8_substr to be loaded
10 * @see http://www.php.net/substr_replace
11 * @see utf8_strlen
12 * @see utf8_substr
13 */
14 function utf8_substr_replace($str, $repl, $start , $length = NULL ) {
15 preg_match_all('/./us', $str, $ar);
16 preg_match_all('/./us', $repl, $rar);
17 if( $length === NULL ) {
18 $length = utf8_strlen($str);
19 }
20 array_splice( $ar[0], $start, $length, $rar[0] );
21 return join('',$ar[0]);
22 }
23