Reputation: 12324
There are many threads about this but none of them helped me solve this problem.
$array=array(
"dépendre"=>"to depend",
"dire"=>"to say",
"distraire"=>"distracted",
"être"=>"to be (being)",
);
Gets encoded like this with json_encode
:
"d\u00e9pendre":"to depend","dire":"to say","distraire":"distracted","\u00eatre":"to be (being)"
So far I have tried this:
array_walk_recursive($array,function($value,$key) {
$key = urlencode(utf8_decode($key));
});
Upvotes: 3
Views: 1694
Reputation: 456
Please check the result from the following code:
<?php
$x=array(
"dépendre"=>"to depend",
"dire"=>"to say",
"distraire"=>"distracted",
"être"=>"to be (being)",
);
$encoded = json_encode($x);
var_dump($x);
var_dump(json_decode($encoded, true));
The string you get in your question is a correctly escaped JSON and could be successfully decoded.
Upvotes: 0
Reputation: 1560
Try this,
json_encode($array, JSON_UNESCAPED_UNICODE);
You should get this result;
{
"dépendre":"to depend",
"dire":"to say",
"distraire":"distracted",
"être":"to be (being)"
}
Upvotes: 6