I like to compare an array from a database against another array to generate a new array of missing ids using isset
or array_key_exists
. Here is the array from my database I am creating.
foreach ($listings as $listing) {
$local_ids[$listing['id']] = 'true';
}
$local_ids = array(
'567' => true,
'568' => true,
'569' => true,
'570' => true,
'571' => true,
'572' => true,
'573' => true
);
$new_ids = array(
'568',
'569',
'572',
'573',
'574',
'575',
'576',
'577'
);
Taking the above two arrays, I would like to cycle through them to give me a result that 567, 570, 571
have been removed.
I altered the $new_ids
as this list may or may not contain ids that are new and not in $local_ids
. These can be ignored, I just need the ones removed.