Why not just make the images generated above associative arrays to start? Then you could do

```php
$insertArray = $imagesToAdd; // simple alias
$deleteArray = array_map($imagesToAdd, function($img) { return $img['page_id']; });
```