php - unset and json decode/encode -
in project have 2d array, stores in db string , processed required. after reading database looks :
[[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 utilize unset() when after json_decode() (somthing this)
unset($array[0][0]);
json_encode() homecoming this:
[{"1":44,"2":69,"3":99},[26,27,39,49,70,80],[20,30,40],[47,57,67],[84,85,86,87]]
change [] {} why happens , how prevent it?
php json
No comments:
Post a Comment