note 89084 added to function.convert-cyr-string
| From: | ("moc.liamg@voglod.yilisav") | Date: | Fri, 20 Feb 2009 20:02:28 +0000 |
| Subject: | note 89084 added to function.convert-cyr-string | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-150904@lists.php.net to get a copy of this message | ||
Unfortunately input data must be a string only. But it is may be changed! ;)
To convert multi-dimensional array I use this recursive function:
<?php
function convert_cyr_array($array,$from,$to){
foreach($array as $key=>$value){
if(is_array($value)) {
$result[$key] = convert_cyr_array($value,$from,$to);
continue;
}
$result[$key] = convert_cyr_string($value,$from,$to);
}
return $result;
}
?>
An example:
<?php
$array[0] = "ÑÐÐÐÐÐ";
$array[1] = "зТХЫÐ";
$array[2] = array("пÐХТÐÐ","ÑÐÐÐÐÐТ");
$array[3] = array(
array("бРÐÐШУÐÐ","нÐÐÐÐТÐÐ"),
array("бÐТÐÐÐУ","ÑÐТУÐÐ")
);
$result = convert_cyr_array($array,"k","w");
/* Returns:
Array
(
[0] => Яблоко
[1] => ÐÑÑÑа
[2] => Array
(
[0] => ÐгÑÑеÑ
[1] => ÐомидоÑ
)
[3] => Array
(
[0] => Array
(
[0] => ÐпелÑÑин
[1] => ÐандаÑин
)
[1] => Array
(
[0] => ÐбÑикоÑ
[1] => ÐеÑÑик
)
)
)*/
?>
----
Server IP: 78.41.104.32
Probable Submitter: 94.158.96.160
----
Manual Page -- http://www.php.net/manual/en/function.convert-cyr-string.php
Edit -- https://master.php.net/note/edit/89084
Del: integrated -- https://master.php.net/note/delete/89084/integrated
Del: useless -- https://master.php.net/note/delete/89084/useless
Del: bad code -- https://master.php.net/note/delete/89084/bad+code
Del: spam -- https://master.php.net/note/delete/89084/spam
Del: non-english -- https://master.php.net/note/delete/89084/non-english
Del: in docs -- https://master.php.net/note/delete/89084/in+docs
Del: other reasons-- https://master.php.net/note/delete/89084
Reject -- https://master.php.net/note/reject/89084
Search -- https://master.php.net/manage/user-notes.php