Problem contact form when checkbox not checked

I want to create a contact form with optional checkboxes.
If one or more checkboxes are checkt it works. But when no checkbox is cheked an error occurs.

implode(): Argument #1 ($pieces) must be of type array, string given

The form:

<input type="checkbox" name="type[]" value="Eins" <?= isset($data['type']) && in_array('Eins', $data['type']) ? 'checked' : '' ?> id="check1"><label for="check1">Eins</label>

<input type="checkbox" name="type[]" value="Zwei" <?= isset($data['type']) && in_array('Zwei', $data['type']) ? 'checked' : '' ?> id="check2"><label for="check2">Zwei</label>

The controller:

...
$data = [
           ...
            'type'  => get('type'),
           ...
        ];
...
try {
                $kirby->email([
                            'type'  => $data['type'],
                        ]
                    ]);
            }
...

The email-template:

<p>Type: <?= implode(',', $type) ?></p>

Thank you for your help.

In the template, I’d try something like this:

<?php if($type): ?>
<p>Type: <?= implode(',', $type) ?></p>
<?php endif; ?>

or

<p>Type: <?= is_array($type) ? implode(',', $type) : 'no type selected' ?></p>

Thank you so much. Both work!!! :pray: