So here we have an array function array_values
but it is working if performing on the same array. Over here i have an object and inside that objst i have set of arrays and with few condition i have to unset few of the keys and reindex the array.
stdClass Object
(
[details] => stdClass Object
(
[first] => 159
[events] => Array
(
[0] => stdClass Object
(
[id]=>1,
[name]=>abc
)
[1] => stdClass Object
(
[id]=>2,
[name]=>abc
)
[2] => stdClass Object
(
[id]=>3,
[name]=>abc
)
)
)
)
Now if i unset the 1 key and do json_encode
and while printing it by doing json_decode
, then it becomes
stdClass Object
(
[details] => stdClass Object
(
[first] => 159
[events] => stdClass Object
(
[0] => stdClass Object
(
[id]=>1,
[name]=>abc
)
[2] => stdClass Object
(
[id]=>3,
[name]=>abc
)
)
)
)
The events node becomes object, I don't want to change it from array to object. My result has to be exactly the same with reindexing the key.