I have an json-encoded array in my database which I like to add elements to. The json from the database looks like this:
{"1549006986":"a27f51b4dba8899c7a278465a873449a"}
Here is the code with which I want to add the element:
$tokenarray = json_decode($_SESSION['logintoken']);
$counttokens = count($tokenarray);
$newtoken = md5(mt_rand());
$datetime = $_SERVER['REQUEST_TIME'];
if ($counttokens < 6){
$tokenarray += [$datetime => $newtoken];
}
$tokenarrayjson = json_encode($tokenarray);
But this line
$tokenarray += [$datetime => $newtoken];
ends up in this error:
Fatal error: Uncaught Error: Unsupported operand types in **SITEURL** Stack trace: #0 {main} thrown in **SITEURL** on line
Can someone tell where im wrong here? From another post on this site, adding elements like this to an array should be valid from php version 5.4. I run on 7.2
Regards andreas