I have a mysqli query that returns a multidimensional array.
I'm trying to encode the php array:
array(3) {
[0]=>
array(8) {
["cod_evento"]=>
string(1) "3"
["titulo"]=>
string(20) "Fiesta de cumpleaños"
["descripcion"]=>
string(23) "Mi fiesta de cumpleaños"
["puntuacion"]=>
string(1) "1"
["direccion"]=>
string(13) "c/ falsa 1234"
["imagen"]=>
string(115) "http://static.guim.co.uk/sys-images/Guardian/Pix/pictures/2014/4/11/1397210130748/Spring-Lamb.-Image-shot-2-011.jpg"
["fecha"]=>
string(19) "2015-01-01 00:00:00"
["cod_usuario"]=>
string(1) "1"
}
[....]
}
But when I try json_encode($array) it returns bool(false)
When I try to encode an array(2) or (1), then it works.
The error happened because your array had a non-unicode character.
From the docs
http://php.net/manual/en/function.json-encode.php
Returns a JSON encoded string on success or FALSE on failure.
to see the reason of failure
http://php.net/manual/en/function.json-last-error-msg.php
To answer the question in the comments
json_encode produce JSON_ERROR_UTF8 from MSSQL-SELECT
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With