3v4l.org

run code in 300+ PHP versions simultaneously
<?php $output = array(); foreach($your_array as $key => $current) { if( !array_key_exists($current, $output) ) { // create new entry $output[$current] = array( $key ); } else { // add to existing entry $output[$current][] = $key; } } print_r($output); ?>
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 2, Position 2 = 15
Branch analysis from position: 2
2 jumps found. (Code = 78) Position 1 = 3, Position 2 = 15
Branch analysis from position: 3
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 11
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 14
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 2
Branch analysis from position: 2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
filename:       /in/LgTcK
function name:  (null)
number of ops:  20
compiled vars:  !0 = $output, !1 = $your_array, !2 = $current, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1      > FE_RESET_R                                       $5      !1, ->15
          2    > > FE_FETCH_R                                       ~6      $5, !2, ->15
          3    >   ASSIGN                                                   !3, ~6
    5     4        ARRAY_KEY_EXISTS                                 ~8      !2, !0
          5        BOOL_NOT                                         ~9      ~8
          6      > JMPZ                                                     ~9, ->11
    7     7    >   INIT_ARRAY                                       ~11     !3
          8        ASSIGN_DIM                                               !0, !2
          9        OP_DATA                                                  ~11
         10      > JMP                                                      ->14
   10    11    >   FETCH_DIM_W                                      $12     !0, !2
         12        ASSIGN_DIM                                               $12
         13        OP_DATA                                                  !3
    4    14    > > JMP                                                      ->2
         15    >   FE_FREE                                                  $5
   14    16        INIT_FCALL                                               'print_r'
         17        SEND_VAR                                                 !0
         18        DO_ICALL                                                 
   15    19      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.82 ms | 1387 KiB | 15 Q