Compare two different arrays and unset element from the first one

bengalistation

New Member
Hey guys. I have a question.I have two different arrays with different structure and i want to compare the values and unset the common values.The first arrays looks like:\[code\]Array ( [0] => Array ( [key1] => value1 [key2] => value2 ) [1] => Array ( [key1] => value3 [key2] => value4 ) [2] => Array ( [key1] => value5 [key2] => value6 ) [3] => Array ( [key1] => value7 [key2] => value9 ) [4] => Array ( [key1] => value11 [key2] => value13 ))\[/code\]The second array looks like:\[code\]Array ( [0] => value1 [1] => value3 [2] => value9)\[/code\]So, i need to parse all the values from the first array and compare the first key with elements from the second array.Something like this\[code\]foreach($array1 as $ar1){ foreach($array2 as $ar2){ if($ar1['key1'] == $ar2){ unset($array1[$ar1]); } }}\[/code\]I've tried everything but it's not working. The first array is generated so i can't change it's structure. The second one is made by hand.After the process, the first array will look like:\[code\] Array ([2] => Array ( [key1] => value5 [key2] => value6 ) [3] => Array ( [key1] => value7 [key2] => value8 ))\[/code\]Help me with some ideas.Thanks
 
Back
Top