3v4l.org

run code in 300+ PHP versions simultaneously
<?php $vendor = [ [ "name" => "module-one", "version" => "1.7.0" ], [ "name" => "module-one", "version" => "1.8.0" ], [ "name" => "module-two", "version" => "1.8.0" ], [ "name" => "module-two", "version" => "1.12.0" ], [ "name" => "module-three", "version" => "1.9.0" ], [ "name" => "module-three", "version" => "1.8.0" ], ]; $result = []; foreach ($vendor as $row) { if (!isset($result[$row['name']]) || version_compare($result[$row['name']]['version'], $row['version'], '<')) { $result[$row['name']] = $row; } } var_export(array_values($result));
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 23
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 47) Position 1 = 8, Position 2 = 18
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 18
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/3BTLv
function name:  (null)
number of ops:  31
compiled vars:  !0 = $vendor, !1 = $result, !2 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        ASSIGN                                                   !1, <array>
   13     2      > FE_RESET_R                                       $5      !0, ->23
          3    > > FE_FETCH_R                                               $5, !2, ->23
   14     4    >   FETCH_DIM_R                                      ~6      !2, 'name'
          5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !1, ~6
          6        BOOL_NOT                                         ~8      ~7
          7      > JMPNZ_EX                                         ~8      ~8, ->18
          8    >   INIT_FCALL                                               'version_compare'
          9        FETCH_DIM_R                                      ~9      !2, 'name'
         10        FETCH_DIM_R                                      ~10     !1, ~9
         11        FETCH_DIM_R                                      ~11     ~10, 'version'
         12        SEND_VAL                                                 ~11
         13        FETCH_DIM_R                                      ~12     !2, 'version'
         14        SEND_VAL                                                 ~12
         15        SEND_VAL                                                 '%3C'
         16        DO_ICALL                                         $13     
         17        BOOL                                             ~8      $13
         18    > > JMPZ                                                     ~8, ->22
   15    19    >   FETCH_DIM_R                                      ~14     !2, 'name'
         20        ASSIGN_DIM                                               !1, ~14
         21        OP_DATA                                                  !2
   13    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $5
   18    24        INIT_FCALL                                               'var_export'
         25        INIT_FCALL                                               'array_values'
         26        SEND_VAR                                                 !1
         27        DO_ICALL                                         $16     
         28        SEND_VAR                                                 $16
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.77 ms | 1013 KiB | 16 Q