3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = 'thing_1'; $pieces = explode('_', $str); $suffix = array_pop($pieces); if ($str == $suffix) { $pieces[] = 1; } else { (int) $suffix; $pieces[count($pieces - 1)] = $suffix + 1; } $new_str = implode('_', $pieces);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 22
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 15
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/0A0eo
function name:  (null)
number of ops:  28
compiled vars:  !0 = $str, !1 = $pieces, !2 = $suffix, !3 = $new_str
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, 'thing_1'
    4     1        INIT_FCALL                                               'explode'
          2        SEND_VAL                                                 '_'
          3        SEND_VAR                                                 !0
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !1, $5
    5     6        INIT_FCALL                                               'array_pop'
          7        SEND_REF                                                 !1
          8        DO_ICALL                                         $7      
          9        ASSIGN                                                   !2, $7
    7    10        IS_EQUAL                                                 !0, !2
         11      > JMPZ                                                     ~9, ->15
    8    12    >   ASSIGN_DIM                                               !1
         13        OP_DATA                                                  1
         14      > JMP                                                      ->22
   11    15    >   CAST                                          4  ~11     !2
         16        FREE                                                     ~11
   12    17        SUB                                              ~12     !1, 1
         18        COUNT                                            ~13     ~12
         19        ADD                                              ~15     !2, 1
         20        ASSIGN_DIM                                               !1, ~13
         21        OP_DATA                                                  ~15
   15    22    >   INIT_FCALL                                               'implode'
         23        SEND_VAL                                                 '_'
         24        SEND_VAR                                                 !1
         25        DO_ICALL                                         $16     
         26        ASSIGN                                                   !3, $16
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
155.01 ms | 936 KiB | 20 Q