3v4l.org

run code in 300+ PHP versions simultaneously
<?php $versions = [ '1', '1.0.2.4', '1.1.0', '1.12.547.8' ]; $max = 0; $new = preg_replace_callback_array( [ "/(\d+).?/" => function($m)use(&$max){ if(($new = strlen($m[1])) > $max) $max = $new; return $m[0]; }, "/(\d+)$|(\d+.)/" => function($m)use(&$max){ return str_pad($m[0], ($m[1] !== "" ? $max : $max+1), "0", STR_PAD_LEFT); } ], $versions); print_r($new);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T5nnf
function name:  (null)
number of ops:  17
compiled vars:  !0 = $versions, !1 = $max, !2 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, 0
    6     2        INIT_FCALL                                               'preg_replace_callback_array'
    9     3        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FT5nnf%3A9%240'
          4        BIND_LEXICAL                                             ~5, !1
   13     5        INIT_ARRAY                                       ~6      ~5, '%2F%28%5Cd%2B%29.%3F%2F'
   15     6        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FT5nnf%3A15%241'
          7        BIND_LEXICAL                                             ~7, !1
   17     8        ADD_ARRAY_ELEMENT                                ~6      ~7, '%2F%28%5Cd%2B%29%24%7C%28%5Cd%2B.%29%2F'
          9        SEND_VAL                                                 ~6
   19    10        SEND_VAR                                                 !0
         11        DO_ICALL                                         $8      
    6    12        ASSIGN                                                   !2, $8
   23    13        INIT_FCALL                                               'print_r'
         14        SEND_VAR                                                 !2
         15        DO_ICALL                                                 
         16      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FT5nnf%3A9%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 8
Branch analysis from position: 7
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 8
filename:       /in/T5nnf
function name:  {closure}
number of ops:  11
compiled vars:  !0 = $m, !1 = $max, !2 = $new
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    9     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   10     2        FETCH_DIM_R                                      ~3      !0, 1
          3        STRLEN                                           ~4      ~3
          4        ASSIGN                                           ~5      !2, ~4
          5        IS_SMALLER                                               !1, ~5
          6      > JMPZ                                                     ~6, ->8
   11     7    >   ASSIGN                                                   !1, !2
   12     8    >   FETCH_DIM_R                                      ~8      !0, 0
          9      > RETURN                                                   ~8
   13    10*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FT5nnf%3A9%240

Function %00%7Bclosure%7D%2Fin%2FT5nnf%3A15%241:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 10
Branch analysis from position: 8
1 jumps found. (Code = 42) Position 1 = 12
Branch analysis from position: 12
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 10
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/T5nnf
function name:  {closure}
number of ops:  18
compiled vars:  !0 = $m, !1 = $max
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   15     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   16     2        INIT_FCALL                                               'str_pad'
          3        FETCH_DIM_R                                      ~2      !0, 0
          4        SEND_VAL                                                 ~2
          5        FETCH_DIM_R                                      ~3      !0, 1
          6        IS_NOT_IDENTICAL                                         ~3, ''
          7      > JMPZ                                                     ~4, ->10
          8    >   QM_ASSIGN                                        ~5      !1
          9      > JMP                                                      ->12
         10    >   ADD                                              ~6      !1, 1
         11        QM_ASSIGN                                        ~5      ~6
         12    >   SEND_VAL                                                 ~5
         13        SEND_VAL                                                 '0'
         14        SEND_VAL                                                 0
         15        DO_ICALL                                         $7      
         16      > RETURN                                                   $7
   17    17*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FT5nnf%3A15%241

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.44 ms | 1405 KiB | 19 Q