I can not convert a string
to a json
, when I try with json_decode()
it returns a value null
.
The string
that I try to convert are like these:
[{id: 6, text: "10", item: 0}, {id: 7, text: "45", item: 1}, {id: 8, text: "3 ^ 2", item : 2}, {id: 9, text: "6", item: 3}, {id: 10, text: "666", item: 4}]
or this:
[{id: 11, text: "18", item: 0}, {id: 12, text: "16", item: 1}, {id: 13, text: "36", item: 2 }]
and that other:
[{id: 14, text: "12", item: 0}, {id: 15, text: "55", item: 1}, {id: 16, text: "111", item: 2 }, {id: 17, text: "9", item: 3}]
They are examples of what I am trying to convert and I try it in the following way:
json_decode($valores[$clave]["respuestas"])