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) . "-" . $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 = 36
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 36
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/iuojl
function name:  (null)
number of ops:  40
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, ->36
    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        CONCAT                                           ~17     $16, '-'
         32        ADD                                              ~18     !1, 1
         33        CONCAT                                           ~19     ~17, ~18
         34        ASSIGN                                                   !2, ~19
         35      > JMP                                                      ->38
    9    36    >   CONCAT                                           ~21     !0, '-1'
         37        ASSIGN                                                   !2, ~21
   12    38    >   ECHO                                                     !2
         39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
174.87 ms | 1396 KiB | 19 Q