6 * @subpackage PluginsShared
8 if (!function_exists('smarty_mb_str_replace')) {
11 * Multibyte string replace
13 * @param string $search the string to be searched
14 * @param string $replace the replacement string
15 * @param string $subject the source string
16 * @param int &$count number of matches found
18 * @return string replaced string
21 function smarty_mb_str_replace($search, $replace, $subject, &$count = 0)
23 if (!is_array($search) && is_array($replace)) {
26 if (is_array($subject)) {
27 // call mb_replace for each single string in $subject
28 foreach ($subject as &$string) {
29 $string = & smarty_mb_str_replace($search, $replace, $string, $c);
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);
39 $n = max(count($search), count($replace));
41 $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c);
48 $parts = mb_split(preg_quote($search), $subject);
49 $count = count($parts) - 1;
50 $subject = implode($replace, $parts);