I retrieve data from a mysql database. I want to make this data available as json:
<?php
$data = array();
foreach($this->dataFromDb as $value){
$data[] = $value;
}
$json = json_encode($data);
echo $json;
?>
Unfortunately this produces null values in the json because e.g. $value['title'] may contain non utf-8 chars like €. To solve this I change this line.
$data[] = array_map(utf8_encode, $value);
But now I have strings like \u00 or \u0080 in the json output. How would I get my normal text like it is stored in db from the json? When I try
print_r(json_decode($json));
I again get strange chars like für 599,95€.
Any ideas?
You also have to
utf8_decode()the data: