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) { $count = count($row); $key = $row[0] . '-' . $row[array_key_last($row)]; if (!isset($result[$key]) || $count < $result[$key][0]) { $result[$key] = [$count, $row]; } } 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 = 17, Position 2 = 21
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 26
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 26
Branch analysis from position: 21
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 27
filename:       /in/EOQRV
function name:  (null)
number of ops:  36
compiled vars:  !0 = $array, !1 = $result, !2 = $row, !3 = $count, !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        ASSIGN                                                   !3, ~8
   13     6        FETCH_DIM_R                                      ~10     !2, 0
          7        CONCAT                                           ~11     ~10, '-'
          8        INIT_FCALL                                               'array_key_last'
          9        SEND_VAR                                                 !2
         10        DO_ICALL                                         $12     
         11        FETCH_DIM_R                                      ~13     !2, $12
         12        CONCAT                                           ~14     ~11, ~13
         13        ASSIGN                                                   !4, ~14
   14    14        ISSET_ISEMPTY_DIM_OBJ                         0  ~16     !1, !4
         15        BOOL_NOT                                         ~17     ~16
         16      > JMPNZ_EX                                         ~17     ~17, ->21
         17    >   FETCH_DIM_R                                      ~18     !1, !4
         18        FETCH_DIM_R                                      ~19     ~18, 0
         19        IS_SMALLER                                       ~20     !3, ~19
         20        BOOL                                             ~17     ~20
         21    > > JMPZ                                                     ~17, ->26
   15    22    >   INIT_ARRAY                                       ~22     !3
         23        ADD_ARRAY_ELEMENT                                ~22     !2
         24        ASSIGN_DIM                                               !1, !4
         25        OP_DATA                                                  ~22
   11    26    > > JMP                                                      ->3
         27    >   FE_FREE                                                  $7
   18    28        INIT_FCALL                                               'var_export'
         29        INIT_FCALL                                               'array_column'
         30        SEND_VAR                                                 !1
         31        SEND_VAL                                                 1
         32        DO_ICALL                                         $23     
         33        SEND_VAR                                                 $23
         34        DO_ICALL                                                 
         35      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.18 ms | 1016 KiB | 16 Q