3v4l.org

run code in 300+ PHP versions simultaneously
<?php $allTags = [ 0 => [ "name" => "TAG-ONE", "video" => "64070,64076,64110,64111", ], 1 => [ "name" => "TAG-TWO", "video" => "64070,64076,64110,64111", ], 2 => [ "name" => "TAG-THREE", "video" => "64111", ] ]; $video_ids = array_flip(array_unique(explode(",",implode(",",array_column($allTags,'video'))))); $result = array_map(function($id){ return ['name' => '','video' => $id]; },array_flip($video_ids)); array_walk($allTags,function($tag_data) use (&$result,&$video_ids){ $ids = explode(",",$tag_data['video']); foreach($ids as $id) $result[$video_ids[$id]]['name'] = empty($result[$video_ids[$id]]['name']) ? $tag_data['name'] : $result[$video_ids[$id]]['name'] . "," . $tag_data['name']; }); print_r($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vlIks
function name:  (null)
number of ops:  40
compiled vars:  !0 = $allTags, !1 = $video_ids, !2 = $result
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   5     0  E >   QM_ASSIGN                                                !0
  18     1        INIT_FCALL                                               'array_flip'
         2        INIT_FCALL                                               'array_unique'
         3        INIT_FCALL                                               'explode'
         4        SEND_VAL                                                 '%2C'
         5        INIT_FCALL                                               'implode'
         6        SEND_VAL                                                 '%2C'
         7        INIT_FCALL                                               'array_column'
         8        SEND_VAR                                                 !0
         9        SEND_VAL                                                 'video'
        10        DO_ICALL                                         $4      
        11        SEND_VAR                                                 $4
        12        DO_ICALL                                         $5      
        13        SEND_VAR                                                 $5
        14        DO_ICALL                                         $6      
        15        SEND_VAR                                                 $6
        16        DO_ICALL                                         $7      
        17        SEND_VAR                                                 $7
        18        DO_ICALL                                         $8      
        19        QM_ASSIGN                                                !1
  20    20        INIT_FCALL                                               'array_map'
        21        RAISE_ABSTRACT_ERROR                             ~10     '%00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a236'
  22    22        SEND_VAL                                                 ~10
        23        INIT_FCALL                                               'array_flip'
        24        SEND_VAR                                                 !1
        25        DO_ICALL                                         $11     
        26        SEND_VAR                                                 $11
        27        DO_ICALL                                         $12     
        28        QM_ASSIGN                                                !2
  24    29        INIT_FCALL                                               'array_walk'
        30        SEND_REF                                                 !0
        31        RAISE_ABSTRACT_ERROR                             ~14     '%00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a378'
        32        BIND_LEXICAL                                             ~14, !2
        33        BIND_LEXICAL                                             ~14, !1
  27    34        SEND_VAL                                                 ~14
        35        DO_ICALL                                                 
  29    36        INIT_FCALL                                               'print_r'
        37        SEND_VAR                                                 !2
        38        DO_ICALL                                                 
        39      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a236:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/vlIks
function name:  {closure}
number of ops:  5
compiled vars:  !0 = $id
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  20     0  E >   RECV                                             !0      
  21     1        INIT_ARRAY                                       ~1      '', 'name'
         2        ADD_ARRAY_ELEMENT                                ~1      !0, 'video'
         3      > RETURN                                                   ~1
  22     4*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a236

Function %00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a378:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 16, Position 2 = 19
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/vlIks
function name:  {closure}
number of ops:  32
compiled vars:  !0 = $tag_data, !1 = $result, !2 = $video_ids, !3 = $ids, !4 = $id
line     #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
  24     0  E >   RECV                                             !0      
         1        BIND_STATIC                                              !1
         2        BIND_STATIC                                              !2
  25     3        INIT_FCALL                                               'explode'
         4        SEND_VAL                                                 '%2C'
         5        FETCH_DIM_R                                      ~5      !0, 'video'
         6        SEND_VAL                                                 ~5
         7        DO_ICALL                                         $6      
         8        QM_ASSIGN                                                !3
  26     9      > FE_RESET_R                                       $8      !3, ->30
        10    > > FE_FETCH_R                                               $8, !4, ->30
        11    >   FETCH_DIM_R                                      ~9      !2, !4
        12        FETCH_DIM_R                                      ~12     !2, !4
        13        FETCH_DIM_IS                                     ~13     !1, ~12
        14        ISSET_ISEMPTY_DIM_OBJ                         1  ~14     ~13, 'name'
        15      > JMPZ                                                     ~14, ->19
        16    >   FETCH_DIM_R                                      ~15     !0, 'name'
        17        ASSIGN_BW_OR                                  0  ~16     ~15
        18      > JMP                                                      ->26
        19    >   FETCH_DIM_R                                      ~17     !2, !4
        20        FETCH_DIM_R                                      ~18     !1, ~17
        21        FETCH_DIM_R                                      ~19     ~18, 'name'
        22        CONCAT                                           ~20     ~19, '%2C'
        23        FETCH_DIM_R                                      ~21     !0, 'name'
        24        CONCAT                                           ~22     ~20, ~21
        25        ASSIGN_BW_OR                                  0  ~16     ~22
        26    >   FETCH_DIM_W                                      $10     !1, ~9
        27        ASSIGN_ADD                                    0          $10, 'name'
        28        OP_DATA                                                  ~16
        29      > JMP                                                      ->10
        30    >   FE_FREE                                                  $8
  27    31      > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FvlIks0x7f721b47a378

Generated using Vulcan Logic Dumper, using php 7.4.0