3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = [ 'Light Blue1', 'Blue2', 'Blue1', 'Black3', 'Black12', 'Black2' ]; $result = []; foreach ($data as $value) { sscanf($value, '%[^0-9]%d', $color, $number); if (!isset($result[$color]) || $result[$color]['number'] < $number) { $result[$color] = ['value' => $value, 'number' => $number]; } } var_export(array_column($result, 'value'));
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 = 13, Position 2 = 17
Branch analysis from position: 13
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 22
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 22
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/fteqY
function name:  (null)
number of ops:  32
compiled vars:  !0 = $data, !1 = $result, !2 = $value, !3 = $color, !4 = $number
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                                       $7      !0, ->23
          3    > > FE_FETCH_R                                               $7, !2, ->23
   14     4    >   INIT_FCALL                                               'sscanf'
          5        SEND_VAR                                                 !2
          6        SEND_VAL                                                 '%25%5B%5E0-9%5D%25d'
          7        SEND_REF                                                 !3
          8        SEND_REF                                                 !4
          9        DO_ICALL                                                 
   15    10        ISSET_ISEMPTY_DIM_OBJ                         0  ~9      !1, !3
         11        BOOL_NOT                                         ~10     ~9
         12      > JMPNZ_EX                                         ~10     ~10, ->17
         13    >   FETCH_DIM_R                                      ~11     !1, !3
         14        FETCH_DIM_R                                      ~12     ~11, 'number'
         15        IS_SMALLER                                       ~13     ~12, !4
         16        BOOL                                             ~10     ~13
         17    > > JMPZ                                                     ~10, ->22
   16    18    >   INIT_ARRAY                                       ~15     !2, 'value'
         19        ADD_ARRAY_ELEMENT                                ~15     !4, 'number'
         20        ASSIGN_DIM                                               !1, !3
         21        OP_DATA                                                  ~15
   13    22    > > JMP                                                      ->3
         23    >   FE_FREE                                                  $7
   19    24        INIT_FCALL                                               'var_export'
         25        INIT_FCALL                                               'array_column'
         26        SEND_VAR                                                 !1
         27        SEND_VAL                                                 'value'
         28        DO_ICALL                                         $16     
         29        SEND_VAR                                                 $16
         30        DO_ICALL                                                 
         31      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
136.36 ms | 1003 KiB | 16 Q