Skip to content

Instantly share code, notes, and snippets.

@L3V147H4N
Last active February 22, 2019 05:48
Show Gist options
  • Save L3V147H4N/a90f088c85cd00fea94c to your computer and use it in GitHub Desktop.
Save L3V147H4N/a90f088c85cd00fea94c to your computer and use it in GitHub Desktop.
PHP ANSI to UTF-8
public static function ansiEncode($array = array(), $fields = array()) {
if(!empty($array)) {
for($i = 0; $i < count($array); $i++) {
foreach($fields as $key => $value) {
try {
json_encode($array[$i][$value]);
} catch (Exception $e) {
$array[$i][$value] = iconv('Windows-1253','UTF-8', $array[$i][$value]);
}
}
}
return $array;
} else {
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment