So I am a bit stuck here, I can do it with foreach loop but I want to find a cleverer way of doing it.
Update: There was something that I've missed in the question. The arrays may come in random order and in different length thus having different keys. Examples below updated.
Here is the case:
Array1
array (
slug1 => England,
slug2 => France,
slug3 => Italy,
slug4 => Germany,
)
Array2
array (
slug2 => 215,
slug1 => 168,
slug4 => 55,
slug5 => 149,
slug3 => 40,
slug6 => 137,
)
I want to intersect those arrays and build new one which has the following elements:
array (
168 => England,
215 => France,
40 => Italy,
55 => Germany,
)
Note: elements are not ordered though that could be achieved easily.