note 101917 modified in function.iconv by danbrown

From: Date: Tue, 18 Jan 2011 14:31:34 +0000
Subject: note 101917 modified in function.iconv by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-175860@lists.php.net to get a copy of this message
I needed a method for recursive iconv. I didn't find one, so wrote it myself and I'd like to share it. Mabye someone will need it. <?php public function recursive_iconv(string $in_charset, string $out_charset, $arr){ if (!is_array($arr)){ return iconv($in_charset, $out_charset, $arr); } $ret = $arr; function array_iconv(&$val, $key, $userdata){ $val = iconv($userdata[0], $userdata[1], $val); } array_walk_recursive($ret, "array_iconv", array($in_charset, $out_charset)); return $ret; } ?> --was-- I needed a method for recursive iconv. I didn't find one, so wrote it myself and I'd like to share it. Mabye someone will need it. public function recursive_iconv(string $in_charset, string $out_charset, $arr){ if (!is_array($arr)){ return iconv($in_charset, $out_charset, $arr); } $ret = $arr; function array_iconv(&$val, $key, $userdata){ $val = iconv($userdata[0], $userdata[1], $val); } array_walk_recursive($ret, "array_iconv", array($in_charset, $out_charset)); return $ret; } http://php.net/manual/en/function.iconv.php

« previous php.notes (#175860) next »