3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str ="(10*2)/(3*40)*100"; $str = str_split($str); // make str an array $arr = array(); $j=0; // counter for new array for($i=0;$i<count($str);$i++){ if(is_numeric($str[$i])){ // if the item is a number $arr[$j] = $str[$i]; // add it to new array $k = $i+1; while(is_numeric($str[$k])){ // while it's still a number append to new array item. $arr[$j] .= $str[$k]; $k++; // add one to counter. if($k == count($str)) break; // if counter is out of bounds, break loop. } $j++; // we are done with this item, add one to counter. $i=$k-1; // set new value to $i }else{ // not number, add it to the new array and add one to array counter. $arr[$j] = $str[$i]; $j++; } } var_dump($arr);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 9
Branch analysis from position: 45
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 37
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 20
Branch analysis from position: 33
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 9
Branch analysis from position: 45
Branch analysis from position: 9
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 27, Position 2 = 28
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
Branch analysis from position: 28
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 45, Position 2 = 9
Branch analysis from position: 45
Branch analysis from position: 9
filename:       /in/p9jZp
function name:  (null)
number of ops:  49
compiled vars:  !0 = $str, !1 = $arr, !2 = $j, !3 = $i, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, '%2810%2A2%29%2F%283%2A40%29%2A100'
    4     1        INIT_FCALL                                               'str_split'
          2        SEND_VAR                                                 !0
          3        DO_ICALL                                         $6      
          4        ASSIGN                                                   !0, $6
    6     5        ASSIGN                                                   !1, <array>
    7     6        ASSIGN                                                   !2, 0
    8     7        ASSIGN                                                   !3, 0
          8      > JMP                                                      ->42
    9     9    >   INIT_FCALL                                               'is_numeric'
         10        FETCH_DIM_R                                      ~11     !0, !3
         11        SEND_VAL                                                 ~11
         12        DO_ICALL                                         $12     
         13      > JMPZ                                                     $12, ->37
   10    14    >   FETCH_DIM_R                                      ~14     !0, !3
         15        ASSIGN_DIM                                               !1, !2
         16        OP_DATA                                                  ~14
   11    17        ADD                                              ~15     !3, 1
         18        ASSIGN                                                   !4, ~15
   12    19      > JMP                                                      ->28
   13    20    >   FETCH_DIM_R                                      ~18     !0, !4
         21        ASSIGN_DIM_OP                .=               8          !1, !2
         22        OP_DATA                                                  ~18
   14    23        PRE_INC                                                  !4
   15    24        COUNT                                            ~20     !0
         25        IS_EQUAL                                                 !4, ~20
         26      > JMPZ                                                     ~21, ->28
         27    > > JMP                                                      ->33
   12    28    >   INIT_FCALL                                               'is_numeric'
         29        FETCH_DIM_R                                      ~22     !0, !4
         30        SEND_VAL                                                 ~22
         31        DO_ICALL                                         $23     
         32      > JMPNZ                                                    $23, ->20
   17    33    >   PRE_INC                                                  !2
   18    34        SUB                                              ~25     !4, 1
         35        ASSIGN                                                   !3, ~25
    9    36      > JMP                                                      ->41
   21    37    >   FETCH_DIM_R                                      ~28     !0, !3
         38        ASSIGN_DIM                                               !1, !2
         39        OP_DATA                                                  ~28
   22    40        PRE_INC                                                  !2
    8    41    >   PRE_INC                                                  !3
         42    >   COUNT                                            ~31     !0
         43        IS_SMALLER                                               !3, ~31
         44      > JMPNZ                                                    ~32, ->9
   26    45    >   INIT_FCALL                                               'var_dump'
         46        SEND_VAR                                                 !1
         47        DO_ICALL                                                 
         48      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.89 ms | 1082 KiB | 16 Q