I have database in german language. I am fetching data from database and create array. problem is some german characters are converted special character. thats why not able to encode array in json. i have also tried by putting header for german language but it is for display purpose so it is not works.
please check below array created
if i copy and paste that same string manually and create array than it create perfect array. can you please solve issue.
after use of
htmlentities($str, ENT_QUOTES, 'UTF-8', false);
you can see have display both string one is fetched from database and one is encoded using htmlentities. you can see last index of array is empty so htmlentities could not encode it.
You need to escape your string. Try this:
// $str, encode quotes, UTF-8 encoding, false (do not double encode). echo htmlentities($str, ENT_QUOTES, 'UTF-8', false);
Replace $str with your string. This should fix your issue.