I add values to an associative array with this code:
$tokenarray += [$datetime => $newtoken];
This works fine. But after I sort the array and shift it with that code:
$sortedarray = krsort($tokenarray, 1);
$shiftedarray = array_shift($sortedarray);
$shiftedarray += [$datetime => $newtoken];
$tokenarrayjson = json_encode($shiftedarray);
This error appears:
Fatal error: Uncaught Error: Unsupported operand types in SITE Stack trace: #0 {main} thrown in SITE on line
$shiftedarray += [$datetime => $newtoken]; <- This line throes the error
Can someone tell my why please? Does array_shift make an object out of my array and if so, how can I prevent it?
Regards, Andreas