3v4l.org

run code in 500+ PHP versions simultaneously
<?php function toArray($string) { $chars = str_split($string); $array = array_reduce($chars, function($result, $current) { $previous = $result[] = array_pop($result); if (is_numeric($previous) && is_numeric($current)) { $result[] = array_pop($result) . $current; } else { $result[] = $current; } return $result; }, []); return array_slice($array, 1); } $input = '6+4*4+100+444*6*13*14'; print_r(toArray($input));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZsvs
function name:  (null)
number of ops:  8
compiled vars:  !0 = $input
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   21     0  E >   ASSIGN                                                       !0, '6%2B4%2A4%2B100%2B444%2A6%2A13%2A14'
   22     1        INIT_FCALL                                                   'print_r'
          2        INIT_FCALL                                                   'toarray'
          3        SEND_VAR                                                     !0
          4        DO_FCALL                                          0  $2      
          5        SEND_VAR                                                     $2
          6        DO_ICALL                                                     
          7      > RETURN                                                       1

Function toarray:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/qZsvs
function name:  toArray
number of ops:  18
compiled vars:  !0 = $string, !1 = $chars, !2 = $array
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   RECV                                                 !0      
    4     1        INIT_FCALL                                                   'str_split'
          2        SEND_VAR                                                     !0
          3        DO_ICALL                                             $3      
          4        ASSIGN                                                       !1, $3
    6     5        INIT_FCALL                                                   'array_reduce'
          6        SEND_VAR                                                     !1
          7        DECLARE_LAMBDA_FUNCTION                              ~5      [0]
   16     8        SEND_VAL                                                     ~5
          9        SEND_VAL                                                     <array>
    6    10        DO_ICALL                                             $6      
         11        ASSIGN                                                       !2, $6
   18    12        INIT_FCALL                                                   'array_slice'
         13        SEND_VAR                                                     !2
         14        SEND_VAL                                                     1
         15        DO_ICALL                                             $8      
         16      > RETURN                                                       $8
   19    17*     > RETURN                                                       null


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 46) Position 1 = 10, Position 2 = 12
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 20
Branch analysis from position: 13
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: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 12
filename:       /in/qZsvs
function name:  {closure:toArray():6}
number of ops:  24
compiled vars:  !0 = $result, !1 = $current, !2 = $previous
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    6     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
    7     2        INIT_FCALL                                                   'array_pop'
          3        SEND_REF                                                     !0
          4        DO_ICALL                                             $4      
          5        ASSIGN_DIM                                           ~3      !0
          6        OP_DATA                                                      $4
          7        ASSIGN                                                       !2, ~3
    9     8        FRAMELESS_ICALL_1                is_numeric          ~6      !2
          9      > JMPZ_EX                                              ~6      ~6, ->12
         10    >   FRAMELESS_ICALL_1                is_numeric          ~7      !1
         11        BOOL                                                 ~6      ~7
         12    > > JMPZ                                                         ~6, ->20
   10    13    >   INIT_FCALL                                                   'array_pop'
         14        SEND_REF                                                     !0
         15        DO_ICALL                                             $9      
         16        CONCAT                                               ~10     $9, !1
         17        ASSIGN_DIM                                                   !0
         18        OP_DATA                                                      ~10
    9    19      > JMP                                                          ->22
   12    20    >   ASSIGN_DIM                                                   !0
         21        OP_DATA                                                      !1
   15    22    > > RETURN                                                       !0
   16    23*     > RETURN                                                       null

End of Dynamic Function 0

End of function toarray

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
165.04 ms | 2242 KiB | 19 Q