i have multidimensional arrays generated by PHP with data from database ,but i have chars like \"č ć š đ ž\" and when i try to output that in json he just returns null , i d
Try this PHP function where you simply pass in the array you wish encoded.
function convertArrayKeysToUtf8(array $array) {
$convertedArray = array();
foreach($array as $key => $value) {
if(!mb_check_encoding($key, 'UTF-8')) $key = utf8_encode($key);
if(is_array($value)) $value = $this->convertArrayKeysToUtf8($value);
$convertedArray[$key] = $value;
}
return $convertedArray;
}
P.s check out php.net for other utf-8 encoding method ideas, but this has worked for me in the past.