Remove one row in structure

I have been trying to have some sort of subscription done via writing and changing structures but while it semes i can change all entries at my will, i cannot unset (delete) a row …

if(get('unsubscribe') && get('unsubemail')){
	$subscriber = $page->subscriber()->yaml();
	foreach($subscriber as &$sub){
		if($sub['active'] == 1 && get('unsubemail') == $sub['email']){
			unset($sub);
		}
	}
	$page->update(['subscriber' => yaml::encode($subscriber)]);
	$success = array(
		'Ihre E-Mail Adresse wurde nun ausgetragen!',
	);
}

it seems like using unset does not work. also $sub = null; or $sub = ‘’; rather breaks the whole thing.

Edit:

if(get('unsubscribe') && get('unsubemail')){
	$subscriber = $page->subscriber()->yaml();
	foreach($subscriber as $key => &$sub){
		if($sub['active'] == 1 && get('unsubemail') == $sub['email']){
			unset($subscriber[$key]);
		}
	}
	$page->update(['subscriber' => yaml::encode($subscriber)]);
	$success = array(
		'Ihre E-Mail Adresse wurde nun ausgetragen!',
	);
}

This seems to work, however in the content file, it’ll use

1:
  - name: Bla
  - email: a@b.cd
2:
.....

instead of

-
  name: bla
  email: a@b.cd
- 
......

i guess that doesn’t make too much of a difference?

since amount of data seems small why to just create a copy skipping/altering some fields instead of manipulating array directly.

another solution could be using a custom subscriber class reading from yaml, having methods for changing data (object not in array) and outputting as array/yaml again.

It doesn’t matter, once you save the page again, you get back the dashes instead of the numbers. In fact, when entering structure fields in Kirby 1, I used numbers, anyway.