Last active
July 24, 2025 03:27
-
-
Save darkcolonist/68285f4a009e84efc587 to your computer and use it in GitHub Desktop.
utf8ize json encode fix
This file contains hidden or 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
/** | |
* fixes the encoding of the values in an associative array | |
* | |
* usage: | |
* $formatted_rows = util::utf8ize($formatted_rows); | |
* echo json_encode($formatted_rows); | |
* | |
* @param assoc $arr array to be processed | |
* @return assoc processed array | |
*/ | |
public static function utf8ize($arr){ | |
if (is_array($arr)) { | |
foreach ($arr as $k => $v) { | |
$arr[$k] = self::utf8ize($v); | |
} | |
} else if (is_string ($arr)) { | |
return utf8_encode($arr); | |
} | |
return $arr; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment