How do I combine 2 arrays in the output?

I display my blog overview as a Masonry gallery that can be filtered:

  • by year (creation date of the post)
  • by tags

How can I combine these two arrays to avoid duplicate output?
I’ve simplified my code, as additional CSS classes and a counter are integrated.

<?php
$callback = function($p) { return $p->date()->toDate('Y'); };
$groupedItems = page('blog')->children()->listed()->sortBy('date', 'desc')->group($callback); 
?>

<ul>

<?php foreach($tags as $tag): ?>
<li class="nav">
<a data-filter=".<?= $tag ?>" href="#"><?= Str::ucfirst(html($tag)) ?></a>
</li>
<?php endforeach ?>

<?php foreach($groupedItems as $year => $aktuelles): ?>
<li class="nav">
<a data-filter=".<?= $year ?>" href="#"><?= $year ?></a>
</li>
<?php endforeach ?>

</ul>