Page Menu
Home
Code
Search
Configure Global Search
Log In
Files
F1137121
shared.mb_str_replace.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Subscribers
None
shared.mb_str_replace.php
View Options
<?php
/**
* Smarty shared plugin
*
* @package Smarty
* @subpackage PluginsShared
*/
if
(!
function_exists
(
'smarty_mb_str_replace'
))
{
/**
* Multibyte string replace
*
* @param string $search the string to be searched
* @param string $replace the replacement string
* @param string $subject the source string
* @param int &$count number of matches found
* @return string replaced string
* @author Rodney Rehm
*/
function
smarty_mb_str_replace
(
$search
,
$replace
,
$subject
,
&
$count
=
0
)
{
if
(!
is_array
(
$search
)
&&
is_array
(
$replace
))
{
return
false
;
}
if
(
is_array
(
$subject
))
{
// call mb_replace for each single string in $subject
foreach
(
$subject
as
&
$string
)
{
$string
=
&
smarty_mb_str_replace
(
$search
,
$replace
,
$string
,
$c
);
$count
+=
$c
;
}
}
elseif
(
is_array
(
$search
))
{
if
(!
is_array
(
$replace
))
{
foreach
(
$search
as
&
$string
)
{
$subject
=
smarty_mb_str_replace
(
$string
,
$replace
,
$subject
,
$c
);
$count
+=
$c
;
}
}
else
{
$n
=
max
(
count
(
$search
),
count
(
$replace
));
while
(
$n
--)
{
$subject
=
smarty_mb_str_replace
(
current
(
$search
),
current
(
$replace
),
$subject
,
$c
);
$count
+=
$c
;
next
(
$search
);
next
(
$replace
);
}
}
}
else
{
$parts
=
mb_split
(
preg_quote
(
$search
),
$subject
);
$count
=
count
(
$parts
)
-
1
;
$subject
=
implode
(
$replace
,
$parts
);
}
return
$subject
;
}
}
?>
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Jul 12, 00:07 (3 w, 1 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25980
Default Alt Text
shared.mb_str_replace.php (1 KB)
Attached To
rZEDHG ZedLegacy
Event Timeline
Log In to Comment