Code

Updated smarty to 1.0.9
[gosa.git] / gosa-core / include / smarty / plugins / shared.mb_str_replace.php
1 <?php
3 if(!function_exists('smarty_mb_str_replace')) {
4   function smarty_mb_str_replace($search, $replace, $subject, &$count=0) { 
5       if (!is_array($search) && is_array($replace)) { 
6           return false; 
7       } 
8       if (is_array($subject)) { 
9           // call mb_replace for each single string in $subject 
10           foreach ($subject as &$string) { 
11               $string = &smarty_mb_str_replace($search, $replace, $string, $c); 
12               $count += $c; 
13           } 
14       } elseif (is_array($search)) { 
15           if (!is_array($replace)) { 
16               foreach ($search as &$string) { 
17                   $subject = smarty_mb_str_replace($string, $replace, $subject, $c); 
18                   $count += $c; 
19               } 
20           } else { 
21               $n = max(count($search), count($replace)); 
22               while ($n--) { 
23                   $subject = smarty_mb_str_replace(current($search), current($replace), $subject, $c); 
24                   $count += $c; 
25                   next($search); 
26                   next($replace); 
27               } 
28           } 
29       } else { 
30           $parts = mb_split(preg_quote($search), $subject); 
31           $count = count($parts)-1; 
32           $subject = implode($replace, $parts); 
33       } 
34       return $subject; 
35   }
36 }
38 ?>