php - How to use array_diff_key properly? -


i have array

array (   500 =>    array (     1 => 1,     6 => 2,     2 => 1,   ),   550 =>    array (     3 => 1,     6 => 2,     4 => 1,     5 => 1,   ), ) 

how next result?

array(     1 => 1,     2 => 1,     3 => 1,     4 => 1,     5 => 1, ) 

i trying use array_diff_key/array_intersect_key, can't goal. suggestions?

upd.

i don't need iterations. direct array_* functions only.

you might looking key difference of union , key intersection:

$array = array_diff_key(     ($a = $array['500']) + ($b = $array['550']),      array_intersect_key($a, $b) ); 

for input array give desired output (demo):

array (     [1] => 1     [2] => 1     [3] => 1     [4] => 1     [5] => 1 ) 

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -