1: <?php
2: 3: 4: 5: 6: 7:
8: if (!function_exists('smarty_mb_str_replace')) {
9:
10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20:
21: function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
22: {
23: if (!is_array($search) && is_array($replace)) {
24: return false;
25: }
26: if (is_array($subject)) {
27:
28: foreach ($subject as &$string) {
29: $string = & smarty_mb_str_replace($search, $replace, $string, $c);
30: $count += $c;
31: }
32: } elseif (is_array($search)) {
33: if (!is_array($replace)) {
34: foreach ($search as &$string) {
35: $subject = smarty_mb_str_replace($string, $replace, $subject, $c);
36: $count += $c;
37: }
38: } else {
39: $n = max(count($search), count($replace));
40: while ($n --) {
41: $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
42: $count += $c;
43: next($search);
44: next($replace);
45: }
46: }
47: } else {
48: $parts = mb_split(preg_quote($search), $subject);
49: $count = count($parts) - 1;
50: $subject = implode($replace, $parts);
51: }
52:
53: return $subject;
54: }
55: }
56: