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", ] ]; $allTagsResult = array(); $format = array(); foreach( $allTags as $a ) { $name = $a['name']; $videos = explode(',', $a['video']); foreach( $videos as $v ) { if( !isset( $format[$v]) ) { $format[$v] = array(); } $format[$v][] = $name; } } foreach( $format as $video => $names) { $allTagsResult[] = array('name' => implode(',', $names), 'video' => $video); } echo '<pre>'; print_r($allTagsResult); die;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 26
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 26
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 14, Position 2 = 24
Branch analysis from position: 14
2 jumps found. (Code = 78) Position 1 = 15, Position 2 = 24
Branch analysis from position: 15
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
Branch analysis from position: 20
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 24
Branch analysis from position: 26
2 jumps found. (Code = 77) Position 1 = 28, Position 2 = 39
Branch analysis from position: 28
2 jumps found. (Code = 78) Position 1 = 29, Position 2 = 39
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
Branch analysis from position: 39
1 jumps found. (Code = 79) Position 1 = -2
Branch analysis from position: 39
Branch analysis from position: 26
filename:       /in/0RL4A
function name:  (null)
number of ops:  46
compiled vars:  !0 = $allTags, !1 = $allTagsResult, !2 = $format, !3 = $a, !4 = $name, !5 = $videos, !6 = $v, !7 = $names, !8 = $video
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   18     1        ASSIGN                                                   !1, <array>
   19     2        ASSIGN                                                   !2, <array>
   21     3      > FE_RESET_R                                       $12     !0, ->26
          4    > > FE_FETCH_R                                               $12, !3, ->26
   22     5    >   FETCH_DIM_R                                      ~13     !3, 'name'
          6        ASSIGN                                                   !4, ~13
   23     7        INIT_FCALL                                               'explode'
          8        SEND_VAL                                                 '%2C'
          9        FETCH_DIM_R                                      ~15     !3, 'video'
         10        SEND_VAL                                                 ~15
         11        DO_ICALL                                         $16     
         12        ASSIGN                                                   !5, $16
   25    13      > FE_RESET_R                                       $18     !5, ->24
         14    > > FE_FETCH_R                                               $18, !6, ->24
   26    15    >   ISSET_ISEMPTY_DIM_OBJ                         0  ~19     !2, !6
         16        BOOL_NOT                                         ~20     ~19
         17      > JMPZ                                                     ~20, ->20
   27    18    >   ASSIGN_DIM                                               !2, !6
         19        OP_DATA                                                  <array>
   29    20    >   FETCH_DIM_W                                      $22     !2, !6
         21        ASSIGN_DIM                                               $22
         22        OP_DATA                                                  !4
   25    23      > JMP                                                      ->14
         24    >   FE_FREE                                                  $18
   21    25      > JMP                                                      ->4
         26    >   FE_FREE                                                  $12
   33    27      > FE_RESET_R                                       $24     !2, ->39
         28    > > FE_FETCH_R                                       ~25     $24, !7, ->39
         29    >   ASSIGN                                                   !8, ~25
   34    30        INIT_FCALL                                               'implode'
         31        SEND_VAL                                                 '%2C'
         32        SEND_VAR                                                 !7
         33        DO_ICALL                                         $28     
         34        INIT_ARRAY                                       ~29     $28, 'name'
         35        ADD_ARRAY_ELEMENT                                ~29     !8, 'video'
         36        ASSIGN_DIM                                               !1
         37        OP_DATA                                                  ~29
   33    38      > JMP                                                      ->28
         39    >   FE_FREE                                                  $24
   36    40        ECHO                                                     '%3Cpre%3E'
   37    41        INIT_FCALL                                               'print_r'
         42        SEND_VAR                                                 !1
         43        DO_ICALL                                                 
   38    44      > EXIT                                                     
   39    45*     > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
177.24 ms | 1400 KiB | 19 Q