3v4l.org

run code in 300+ PHP versions simultaneously
<?php $string = "Fasd-2"; $sub=substr($string, strrpos($string, "-")+1, strlen($string) - strrpos($string, "-")); if (is_numeric($sub)) { $newString = substr($string, 0, strlen($string) - strlen($sub) -1); $newString = $newString . "-" . $sub+1; } else { $newString = $string . "-1"; } echo $newString;
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 22, Position 2 = 37
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 39
Branch analysis from position: 39
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DqJl8
function name:  (null)
number of ops:  41
compiled vars:  !0 = $string, !1 = $sub, !2 = $newString
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'Fasd-2'
    5     1        INIT_FCALL                                               'substr'
          2        SEND_VAR                                                 !0
          3        INIT_FCALL                                               'strrpos'
          4        SEND_VAR                                                 !0
          5        SEND_VAL                                                 '-'
          6        DO_ICALL                                         $4      
          7        ADD                                              ~5      $4, 1
          8        SEND_VAL                                                 ~5
          9        STRLEN                                           ~6      !0
         10        INIT_FCALL                                               'strrpos'
         11        SEND_VAR                                                 !0
         12        SEND_VAL                                                 '-'
         13        DO_ICALL                                         $7      
         14        SUB                                              ~8      ~6, $7
         15        SEND_VAL                                                 ~8
         16        DO_ICALL                                         $9      
         17        ASSIGN                                                   !1, $9
    6    18        INIT_FCALL                                               'is_numeric'
         19        SEND_VAR                                                 !1
         20        DO_ICALL                                         $11     
         21      > JMPZ                                                     $11, ->37
    7    22    >   INIT_FCALL                                               'substr'
         23        SEND_VAR                                                 !0
         24        SEND_VAL                                                 0
         25        STRLEN                                           ~12     !0
         26        STRLEN                                           ~13     !1
         27        SUB                                              ~14     ~12, ~13
         28        SUB                                              ~15     ~14, 1
         29        SEND_VAL                                                 ~15
         30        DO_ICALL                                         $16     
         31        ASSIGN                                                   !2, $16
    8    32        CONCAT                                           ~18     !2, '-'
         33        ADD                                              ~19     !1, 1
         34        CONCAT                                           ~20     ~18, ~19
         35        ASSIGN                                                   !2, ~20
         36      > JMP                                                      ->39
   10    37    >   CONCAT                                           ~22     !0, '-1'
         38        ASSIGN                                                   !2, ~22
   13    39    >   ECHO                                                     !2
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
169.84 ms | 1401 KiB | 19 Q