3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [1, 2, 3], [1, 3], [1, 2, 4, 3], [1, 3, 4] ]; $result = []; foreach ($array as $row) { $cache = [count($row), $row]; array_splice($row, 1, -1); $key = implode('-', $row); if (!isset($result[$key]) || $cache[0] < $result[$key][0]) { $result[$key] = $cache; } } var_export(array_column($result, 1));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 30
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 30
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 21, Position 2 = 26
Branch analysis from position: 21
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 29
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/buDIU
function name:  (null)
number of ops:  39
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $cache, !4 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   10     1        ASSIGN                                                   !1, <array>
   11     2      > FE_RESET_R                                       $7      !0, ->30
          3    > > FE_FETCH_R                                               $7, !2, ->30
   12     4    >   COUNT                                            ~8      !2
          5        INIT_ARRAY                                       ~9      ~8
          6        ADD_ARRAY_ELEMENT                                ~9      !2
          7        ASSIGN                                                   !3, ~9
   13     8        INIT_FCALL                                               'array_splice'
          9        SEND_REF                                                 !2
         10        SEND_VAL                                                 1
         11        SEND_VAL                                                 -1
         12        DO_ICALL                                                 
   14    13        INIT_FCALL                                               'implode'
         14        SEND_VAL                                                 '-'
         15        SEND_VAR                                                 !2
         16        DO_ICALL                                         $12     
         17        ASSIGN                                                   !4, $12
   15    18        ISSET_ISEMPTY_DIM_OBJ                         0  ~14     !1, !4
         19        BOOL_NOT                                         ~15     ~14
         20      > JMPNZ_EX                                         ~15     ~15, ->26
         21    >   FETCH_DIM_R                                      ~16     !3, 0
         22        FETCH_DIM_R                                      ~17     !1, !4
         23        FETCH_DIM_R                                      ~18     ~17, 0
         24        IS_SMALLER                                       ~19     ~16, ~18
         25        BOOL                                             ~15     ~19
         26    > > JMPZ                                                     ~15, ->29
   16    27    >   ASSIGN_DIM                                               !1, !4
         28        OP_DATA                                                  !3
   11    29    > > JMP                                                      ->3
         30    >   FE_FREE                                                  $7
   19    31        INIT_FCALL                                               'var_export'
         32        INIT_FCALL                                               'array_column'
         33        SEND_VAR                                                 !1
         34        SEND_VAL                                                 1
         35        DO_ICALL                                         $21     
         36        SEND_VAR                                                 $21
         37        DO_ICALL                                                 
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
149.91 ms | 1022 KiB | 17 Q