3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = ['TestAgent1', 'TestAgent', 'TestAgent1', 'TestAgent1', 'TestAgent2', 'TestAgent2', 'TestAgent2']; $values = ['2019-01', '2019-04', '2019-05', '2019-06', '2019-04', '2019-05', '2019-06']; $unique = array_unique($names); foreach($unique as $name){ $res[] = array_merge([$name], array_intersect_key($values, array_intersect($names, [$name]))); } print_r($res);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 25
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 25
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/MWjv0
function name:  (null)
number of ops:  30
compiled vars:  !0 = $names, !1 = $values, !2 = $unique, !3 = $name, !4 = $res
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_unique'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $7      
          5        ASSIGN                                                   !2, $7
    8     6      > FE_RESET_R                                       $9      !2, ->25
          7    > > FE_FETCH_R                                               $9, !3, ->25
    9     8    >   INIT_FCALL                                               'array_merge'
          9        INIT_ARRAY                                       ~11     !3
         10        SEND_VAL                                                 ~11
         11        INIT_FCALL                                               'array_intersect_key'
         12        SEND_VAR                                                 !1
         13        INIT_FCALL                                               'array_intersect'
         14        SEND_VAR                                                 !0
         15        INIT_ARRAY                                       ~12     !3
         16        SEND_VAL                                                 ~12
         17        DO_ICALL                                         $13     
         18        SEND_VAR                                                 $13
         19        DO_ICALL                                         $14     
         20        SEND_VAR                                                 $14
         21        DO_ICALL                                         $15     
         22        ASSIGN_DIM                                               !4
         23        OP_DATA                                                  $15
    8    24      > JMP                                                      ->7
         25    >   FE_FREE                                                  $9
   11    26        INIT_FCALL                                               'print_r'
         27        SEND_VAR                                                 !4
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.13 ms | 1010 KiB | 18 Q