I am getting [{"2016":"200"},{"2017":"200"}]
This JSON string from server , I want to append another object ie. {"2018":"324"}
at the end of the existing JSON array and want to delete object at the 0th index the existing JSON array so that the my desired result [{"2017":"200"}{"2018":"324"}]
can be obtained.
Here's what i am doing
$str = json_decode($x1,TRUE); //x1 is my JSON
array_push($str, array("2018"=>"324")); //adding another object
unset($str[0]); //removing 0th index
$s = json_encode($str,TRUE); //making JSON again
echo $s;
Problem here is $s
giving output in object form like {"1":{"2017":"200"},"2":{"2018":"35"}}
While what is wanted is [{"2017":"200"}{"2018":"324"}]