note 89084 added to function.convert-cyr-string

From: 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

« previous php.notes (#150904) next »