3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [[6],[6],[6],[5,1],[3,3],[3,3],[3,2,1]]; $result = []; foreach ($array as $row) { $key = json_encode($row); $result[$key] = [$row, ($result[$key][1] ?? 0) + 1]; } echo json_encode(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 18
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 18
Branch analysis from position: 4
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 18
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 18
filename:       /in/U5hBg
function name:  (null)
number of ops:  27
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN                                                   !1, <array>
    6     2      > FE_RESET_R                                       $6      !0, ->18
          3    > > FE_FETCH_R                                               $6, !2, ->18
    7     4    >   INIT_FCALL                                               'json_encode'
          5        SEND_VAR                                                 !2
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !3, $7
    8     8        INIT_ARRAY                                       ~10     !2
          9        FETCH_DIM_IS                                     ~11     !1, !3
         10        FETCH_DIM_IS                                     ~12     ~11, 1
         11        COALESCE                                         ~13     ~12
         12        QM_ASSIGN                                        ~13     0
         13        ADD                                              ~14     ~13, 1
         14        ADD_ARRAY_ELEMENT                                ~10     ~14
         15        ASSIGN_DIM                                               !1, !3
         16        OP_DATA                                                  ~10
    6    17      > JMP                                                      ->3
         18    >   FE_FREE                                                  $6
   10    19        INIT_FCALL                                               'json_encode'
         20        INIT_FCALL                                               'array_values'
         21        SEND_VAR                                                 !1
         22        DO_ICALL                                         $15     
         23        SEND_VAR                                                 $15
         24        DO_ICALL                                         $16     
         25        ECHO                                                     $16
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
141.13 ms | 1001 KiB | 15 Q