php - Hash Style Array to Compare 2 Arrays -


i compare array database against array generate new array of missing ids using isset or array_key_exists. here array database creating.

foreach ($listings $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 above 2 arrays, cycle through them give me result 567, 570, 571 have been removed.

i altered $new_ids list may or may not contain ids new , not in $local_ids. these can ignored, need ones removed.

i know method goes this

<?php $a1 = array("a" => "one", "two", "three", "four"); $a2 = array("b" => "one", "two", "three"); $result = array_diff($array1, $array2);  print_r($result); ?> or  <?php $a1 = array("a" => "one", "b" => "two", "c" => "three", "four"); $a2 = array("a" => "one", "two", "three"); $result = array_diff_assoc($array1, $array2); print_r($result); ?> 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -