3v4l.org

run code in 500+ PHP versions simultaneously
<?php $string = 'A1-3, A14, 5B-7'; $result = []; foreach (explode(', ', $string) as $value) { if (sscanf($value, '%[A-Z]%d-%d', $letter, $low, $high) === 3) { for ($x = $low; $x <= $high; ++$x) { $result[] = $letter . $x; } } elseif (sscanf($value, '%d%[A-Z]-%d', $low, $letter, $high) === 3) { for ($x = $low; $x <= $high; ++$x) { $result[] = $x . $letter; } } else { $result[] = $value; } } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 7, Position 2 = 47
Branch analysis from position: 7
2 jumps found. (Code = 78) Position 1 = 8, Position 2 = 47
Branch analysis from position: 8
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 26
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 19
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 19
2 jumps found. (Code = 44) Position 1 = 25, Position 2 = 19
Branch analysis from position: 25
Branch analysis from position: 19
Branch analysis from position: 26
2 jumps found. (Code = 43) Position 1 = 35, Position 2 = 44
Branch analysis from position: 35
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 37
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 46
Branch analysis from position: 46
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 43, Position 2 = 37
Branch analysis from position: 43
Branch analysis from position: 37
Branch analysis from position: 44
1 jumps found. (Code = 42) Position 1 = 7
Branch analysis from position: 7
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
filename:       /in/FfJt4
function name:  (null)
number of ops:  52
compiled vars:  !0 = $string, !1 = $result, !2 = $value, !3 = $letter, !4 = $low, !5 = $high, !6 = $x
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, 'A1-3%2C+A14%2C+5B-7'
    5     1        ASSIGN                                                       !1, <array>
    6     2        INIT_FCALL                                                   'explode'
          3        SEND_VAL                                                     '%2C+'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $9      
          6      > FE_RESET_R                                           $10     $9, ->47
          7    > > FE_FETCH_R                                                   $10, !2, ->47
    7     8    >   INIT_FCALL                                                   'sscanf'
          9        SEND_VAR                                                     !2
         10        SEND_VAL                                                     '%25%5BA-Z%5D%25d-%25d'
         11        SEND_REF                                                     !3
         12        SEND_REF                                                     !4
         13        SEND_REF                                                     !5
         14        DO_ICALL                                             $11     
         15        IS_IDENTICAL                                                 $11, 3
         16      > JMPZ                                                         ~12, ->26
    8    17    >   ASSIGN                                                       !6, !4
         18      > JMP                                                          ->23
    9    19    >   CONCAT                                               ~15     !3, !6
         20        ASSIGN_DIM                                                   !1
         21        OP_DATA                                                      ~15
    8    22        PRE_INC                                                      !6
         23    >   IS_SMALLER_OR_EQUAL                                          !6, !5
         24      > JMPNZ                                                        ~17, ->19
    7    25    > > JMP                                                          ->46
   11    26    >   INIT_FCALL                                                   'sscanf'
         27        SEND_VAR                                                     !2
         28        SEND_VAL                                                     '%25d%25%5BA-Z%5D-%25d'
         29        SEND_REF                                                     !4
         30        SEND_REF                                                     !3
         31        SEND_REF                                                     !5
         32        DO_ICALL                                             $18     
         33        IS_IDENTICAL                                                 $18, 3
         34      > JMPZ                                                         ~19, ->44
   12    35    >   ASSIGN                                                       !6, !4
         36      > JMP                                                          ->41
   13    37    >   CONCAT                                               ~22     !6, !3
         38        ASSIGN_DIM                                                   !1
         39        OP_DATA                                                      ~22
   12    40        PRE_INC                                                      !6
         41    >   IS_SMALLER_OR_EQUAL                                          !6, !5
         42      > JMPNZ                                                        ~24, ->37
   11    43    > > JMP                                                          ->46
   16    44    >   ASSIGN_DIM                                                   !1
         45        OP_DATA                                                      !2
    6    46    > > JMP                                                          ->7
         47    >   FE_FREE                                                      $10
   19    48        INIT_FCALL                                                   'var_export'
         49        SEND_VAR                                                     !1
         50        DO_ICALL                                                     
         51      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
175.23 ms | 1729 KiB | 16 Q