3v4l.org

run code in 500+ 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 = 27
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 27
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 18, Position 2 = 23
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 24, Position 2 = 26
Branch analysis from position: 24
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 23
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/buDIU
function name:  (null)
number of ops:  36
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, ->27
          3    > > FE_FETCH_R                                                   $7, !2, ->27
   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        FRAMELESS_ICALL_2                implode             ~12     '-', !2
         14        ASSIGN                                                       !4, ~12
   15    15        ISSET_ISEMPTY_DIM_OBJ                             0  ~14     !1, !4
         16        BOOL_NOT                                             ~15     ~14
         17      > JMPNZ_EX                                             ~15     ~15, ->23
         18    >   FETCH_DIM_R                                          ~16     !3, 0
         19        FETCH_DIM_R                                          ~17     !1, !4
         20        FETCH_DIM_R                                          ~18     ~17, 0
         21        IS_SMALLER                                           ~19     ~16, ~18
         22        BOOL                                                 ~15     ~19
         23    > > JMPZ                                                         ~15, ->26
   16    24    >   ASSIGN_DIM                                                   !1, !4
         25        OP_DATA                                                      !3
   11    26    > > JMP                                                          ->3
         27    >   FE_FREE                                                      $7
   19    28        INIT_FCALL                                                   'var_export'
         29        INIT_FCALL                                                   'array_column'
         30        SEND_VAR                                                     !1
         31        SEND_VAL                                                     1
         32        DO_ICALL                                             $21     
         33        SEND_VAR                                                     $21
         34        DO_ICALL                                                     
         35      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
166.88 ms | 1310 KiB | 11 Q