3v4l.org

run code in 500+ 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 = 38
Branch analysis from position: 38
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 12, Position 2 = 33
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 29, Position 2 = 18
Branch analysis from position: 29
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
Branch analysis from position: 9
Branch analysis from position: 18
2 jumps found. (Code = 43) Position 1 = 25, Position 2 = 26
Branch analysis from position: 25
1 jumps found. (Code = 42) Position 1 = 29
Branch analysis from position: 29
Branch analysis from position: 26
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 41, Position 2 = 9
Branch analysis from position: 41
Branch analysis from position: 9
filename:       /in/p9jZp
function name:  (null)
number of ops:  45
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                                                          ->38
    9     9    >   FETCH_DIM_R                                          ~11     !0, !3
         10        FRAMELESS_ICALL_1                is_numeric          ~12     ~11
         11      > JMPZ                                                         ~12, ->33
   10    12    >   FETCH_DIM_R                                          ~14     !0, !3
         13        ASSIGN_DIM                                                   !1, !2
         14        OP_DATA                                                      ~14
   11    15        ADD                                                  ~15     !3, 1
         16        ASSIGN                                                       !4, ~15
   12    17      > JMP                                                          ->26
   13    18    >   FETCH_DIM_R                                          ~18     !0, !4
         19        ASSIGN_DIM_OP                    .=               8          !1, !2
         20        OP_DATA                                                      ~18
   14    21        PRE_INC                                                      !4
   15    22        COUNT                                                ~20     !0
         23        IS_EQUAL                                                     !4, ~20
         24      > JMPZ                                                         ~21, ->26
         25    > > JMP                                                          ->29
   12    26    >   FETCH_DIM_R                                          ~22     !0, !4
         27        FRAMELESS_ICALL_1                is_numeric          ~23     ~22
         28      > JMPNZ                                                        ~23, ->18
   17    29    >   PRE_INC                                                      !2
   18    30        SUB                                                  ~25     !4, 1
         31        ASSIGN                                                       !3, ~25
    9    32      > JMP                                                          ->37
   21    33    >   FETCH_DIM_R                                          ~28     !0, !3
         34        ASSIGN_DIM                                                   !1, !2
         35        OP_DATA                                                      ~28
   22    36        PRE_INC                                                      !2
    8    37    >   PRE_INC                                                      !3
         38    >   COUNT                                                ~31     !0
         39        IS_SMALLER                                                   !3, ~31
         40      > JMPNZ                                                        ~32, ->9
   26    41    >   INIT_FCALL                                                   'var_dump'
         42        SEND_VAR                                                     !1
         43        DO_ICALL                                                     
         44      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
200.79 ms | 2687 KiB | 15 Q