I have the following array of arrays:
array(1) {
[0]=>
array(2) {
[0]=>
array(2) {
[0]=>
string(3) "abc"
[1]=>
string(3) "įāē"
}
[1]=>
array(2) {
[0]=>
string(3) "čaē"
[1]=>
string(3) "qwe"
}
}
}
I am using the bellow code to echo the result on a page:
echo json_encode($array);
I get the following result on my page:
[[["abc",null],[null,"qwe"]]]
Every string with special char is converted to null.
So I´ve tried utf8_encode
on each of the element in the array:
foreach($array as &$subarray1){
foreach($subarray1 as &$subarray2){
foreach($subarray2 as &$subarray3){
$subarray3 = utf8_encode($subarray3);
}
}
}
But I get the following result:
[[["abc","\u00e1\u00e2\u00e7"],["\u00e8a\u00e7","qwe"]]]
What is the proper way to encode this?