3v4l.org

run code in 500+ PHP versions simultaneously
<?php $array = [ 'visitPoints'=>[ 20=>[2,5,6,8,10,11], 35=>[2,5,6], 57=>[1] ], 'islands'=>[ 20=>[5,10,11], 35=>[5,6] ], 'animals'=>[ 20=>[5,11], 35=>[] ] ]; /*$result = [ 20=>[5,11], 35=>[], 57=>[], ];*/ $result = array_shift($array) ?? []; foreach ($array as $rows) { foreach ($result as $k => $row) { $result[$k] = array_values(array_intersect($row, $rows[$k] ?? [])); } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 27
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 27
Branch analysis from position: 9
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 25
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 25
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/9Drtq
function name:  (null)
number of ops:  32
compiled vars:  !0 = $array, !1 = $result, !2 = $rows, !3 = $row, !4 = $k
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                       !0, <array>
   24     1        INIT_FCALL                                                   'array_shift'
          2        SEND_REF                                                     !0
          3        DO_ICALL                                             $6      
          4        COALESCE                                             ~7      $6
          5        QM_ASSIGN                                            ~7      <array>
          6        ASSIGN                                                       !1, ~7
   25     7      > FE_RESET_R                                           $9      !0, ->27
          8    > > FE_FETCH_R                                                   $9, !2, ->27
   26     9    > > FE_RESET_R                                           $10     !1, ->25
         10    > > FE_FETCH_R                                           ~11     $10, !3, ->25
         11    >   ASSIGN                                                       !4, ~11
   27    12        INIT_FCALL                                                   'array_values'
         13        INIT_FCALL                                                   'array_intersect'
         14        SEND_VAR                                                     !3
         15        FETCH_DIM_IS                                         ~14     !2, !4
         16        COALESCE                                             ~15     ~14
         17        QM_ASSIGN                                            ~15     <array>
         18        SEND_VAL                                                     ~15
         19        DO_ICALL                                             $16     
         20        SEND_VAR                                                     $16
         21        DO_ICALL                                             $17     
         22        ASSIGN_DIM                                                   !1, !4
         23        OP_DATA                                                      $17
   26    24      > JMP                                                          ->10
         25    >   FE_FREE                                                      $10
   25    26      > JMP                                                          ->8
         27    >   FE_FREE                                                      $9
   30    28        INIT_FCALL                                                   'var_export'
         29        SEND_VAR                                                     !1
         30        DO_ICALL                                                     
         31      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
157.57 ms | 1603 KiB | 17 Q