In my project i have 2d array, stores it in the DB as a string and processed as required. after reading from the database looks like :
[[19,44,69,99],[26,27,39,49,70,80],[20,30,40],[47,57,67],[84,85,86,87]]
after json_decode() looks like:
Array
(
[0] => Array
(
[0] => 19
[1] => 44
[2] => 69
[3] => 99
)
[1] => Array
(
[0] => 26
[1] => 27
[2] => 39
[3] => 49
[4] => 70
[5] => 80
)
[2] => Array
(
[0] => 20
[1] => 30
[2] => 40
)
[3] => Array
(
[0] => 47
[1] => 57
[2] => 67
)
[4] => Array
(
[0] => 84
[1] => 85
[2] => 86
[3] => 87
)
)
and after json_encode():
[[19,44,69,99],[26,27,39,49,70,80],[20,30,40],[47,57,67],[84,85,86,87]]
But! If i use unset() when she is after json_decode() (somthing like this)
unset($Array[0][0]);
json_encode() will be return this:
[{"1":44,"2":69,"3":99},[26,27,39,49,70,80],[20,30,40],[47,57,67],[84,85,86,87]]
Change [] to {} why it happens and how to prevent it?