get the matched value from 2 multidimensional array in php by id

Solutions on MaxInterview for get the matched value from 2 multidimensional array in php by id by the best coders in the world

showing results for - "get the matched value from 2 multidimensional array in php by id"
Pedro
24 Nov 2018
1<?php
2  $a = Array(
3      Array('id' => 1, 'affiliate_id' => 190),
4      Array('id' => 2, 'affiliate_id' => 946)
5  );
6
7  $b = Array(
8      Array('id' => 1, 'user_id' => 190),
9      Array('id' => 2, 'user_id' => 246),
10      Array('id' => 3, 'user_id' => 249),
11      Array('id' => 3, 'user_id' => 250)
12  );
13
14  $c = array_map(function ($arr) { return $arr['affiliate_id']; }, $a);
15  $d = array_map(function ($arr) { return $arr['user_id']; }, $b);
16
17  $e = array_intersect($c, $d);
18
19  // Output
20  // Array ( [0] => 190 )
21
22?>