3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 2 => [ 3, ], 3 => [ 8, ], 4 => [ 5, ], 5 => [ 8, ], 6 => [ 3, 8, ], 7 => [ 2, 5, ], 8 => [ 3, 8, ], ]; $occurrences = []; $mapped = array_map(function (array $values) use (&$occurrences) { $index = serialize($values); if (!array_key_exists($index, $occurrences)) { $occurrences[$index] = 1; return 0; } $occurrences[$index]++; return $occurrences[$index] - 1; }, $data); var_dump($mapped);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oWBcS
function name:  (null)
number of ops:  13
compiled vars:  !0 = $data, !1 = $occurrences, !2 = $mapped
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   30     1        ASSIGN                                                   !1, <array>
   32     2        INIT_FCALL                                               'array_map'
          3        DECLARE_LAMBDA_FUNCTION                          ~5      [0]
          4        BIND_LEXICAL                                             ~5, !1
   45     5        SEND_VAL                                                 ~5
          6        SEND_VAR                                                 !0
   32     7        DO_ICALL                                         $6      
          8        ASSIGN                                                   !2, $6
   47     9        INIT_FCALL                                               'var_dump'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/oWBcS
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $values, !1 = $occurrences, !2 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   32     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   33     2        INIT_FCALL                                               'serialize'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $3      
          5        ASSIGN                                                   !2, $3
   35     6        ARRAY_KEY_EXISTS                                 ~5      !2, !1
          7        BOOL_NOT                                         ~6      ~5
          8      > JMPZ                                                     ~6, ->12
   36     9    >   ASSIGN_DIM                                               !1, !2
         10        OP_DATA                                                  1
   38    11      > RETURN                                                   0
   41    12    >   FETCH_DIM_RW                                     $8      !1, !2
         13        PRE_INC                                                  $8
   43    14        FETCH_DIM_R                                      ~10     !1, !2
         15        SUB                                              ~11     ~10, 1
         16      > RETURN                                                   ~11
   45    17*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.83 ms | 1013 KiB | 16 Q