s0c0 Posted June 17, 2011 Share Posted June 17, 2011 Hello, I receive the following FATAL error: json_encode() [<a href='function.json-encode'>function.json-encode</a>]: Invalid UTF-8 sequence in argument Here is the code: echo json_encode($cart->get_products()); get_products returns an array even if its just an empty array. Does anyone have any experience with this or seen it before. Couldn't find any solutions through googling around and am wondering if I need pass the encoded data through something like http://www.php.net/manual/en/function.utf8-encode.php Please advise. Quote Link to comment Share on other sites More sharing options...
2-d Posted June 19, 2011 Share Posted June 19, 2011 Hello, I've seen this error before when invalid utf-8 characters were being encoded. So most likely whatever your function is returning has an invalid utf8 character in it. I resolved the issue by doing somthing like this to clean out the invalid characters: <?php $newstring = iconv('UTF-8', 'ISO-8859-1//IGNORE', $string); Where the $string variable is the utf-8 string with the invalid character. I'm not too sure if this is a valid solution to you, but it may be something to look into. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.