Reputation: 71
I have an hidden element that receives a JSON string from a multidimensional array. When I try to get this string it returns null because of some accents. The original array is ISO-8859-1. How can I adjust this? It will be parsed with JS to populate a select field.
PHP - data source
$SubjectListChild1 = array(array ('Code' => 1, 'MainLabel' => 'Dúvidas sobre o processo'));
$data = json_encode($SubjectListChild1);
JS - getting data
var childSubject = (jQuery('#SubjectListChild').html());
var obj = jQuery.parseJSON(childSubject);
Upvotes: 1
Views: 4880
Reputation: 479
Have a look into utf8-encoding the array strings: utf8_encode($string)
json_encode only works on utf-8 encoded data.
Edit: It's possible you can serialize the array, utf-8 encode it, and unserialize it. But I haven't tested this.
Upvotes: 2