Created
June 7, 2014 04:45
-
-
Save pafnuty/df8902ea255dc77fc304 to your computer and use it in GitHub Desktop.
Костыль для 1251
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/** | |
* Функция конвертирует utf8 в 1251 | |
* @param $arr | |
* @param $charset | |
* | |
* @return array|object|string | |
*/ | |
function iconv_1251($arr, $charset) { | |
if ($charset == 'windows-1251') { | |
return $arr; | |
} | |
$returnObj = false; | |
if (is_object($arr)) { | |
$arr = (array)$arr; | |
$returnObj = true; | |
} | |
if (is_array($arr)) { | |
$returnArr = array_map('iconv_1251', $arr); | |
} | |
else { | |
$returnArr = iconv('UTF-8', 'WINDOWS-1251', $arr); | |
} | |
return ($returnObj) ? (object)$returnArr : $returnArr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment