&$item) { if (isset($item["gtmFinality"]) && is_string($item["gtmFinality"])) { // Convert the string to an associative array with a true value $item["gtmFinality"] = [$item["gtmFinality"] => true]; } if ($key === CookiesPlusFinality::MARKETING_COOKIE) { // Add new keys to the gtmFinality array $newConsents = [ "ad_user_data" => true, "ad_personalization" => true, ]; // Merge the existing gtmFinality array with the new keys $item["gtmFinality"] = array_merge($item["gtmFinality"], $newConsents); } } unset($item); return true; }