3v4l.org

run code in 300+ PHP versions simultaneously
<?php function stringMultiplicate($first, $second) { // Create array include result of 1 number in $second string * first $result = []; $strFirst = (string)$first; $strSecond = (string)$second; $maxLength = 0; for ($i = strlen($strSecond) - 1; $i >= 0; $i--) { $index = $i; $number = (int)$strSecond[$i]; $result[$index] = ''; $k = strlen($strSecond) - 1 - $i; $div = 0; for ($j = (strlen($strFirst) - 1); $j >= 0; $j--) { while ($k != 0) { $result[$index] .= '0'; $k--; } $next = ($number * $strFirst[$j] + $div); if (strlen($next) > 1 && $j != 0) { $result[$index] .= ((string)$next)[strlen($next) - 1]; $div = ((string)$next)[0]; } else { $result[$index] .= $number * $strFirst[$j] + $div; $div = 0; } } if (strlen($result[$index]) > $maxLength) { $maxLength = $result[$index]; } $result[$index] = strrev($result[$index]); } $multi = []; for ($j = 0; $j < $maxLength; $j++) { $sum = 0; for ($i = 0; $i < count($result); $i++) { var_dump($result[$i]); if (!isset($result[$i][$j])) { $result[$i][$j] = 0; } $sum += (int)$result[$i][$j]; } $multi[$i] = $sum; } return $multi; } var_dump(stringMultiplicate(12345, 123)); var_dump(12345*123);

Abusive script

This script was stopped while abusing our resources

Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/c1drQ
function name:  (null)
number of ops:  11
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   56     0  E >   INIT_FCALL                                               'var_dump'
          1        INIT_FCALL                                               'stringmultiplicate'
          2        SEND_VAL                                                 12345
          3        SEND_VAL                                                 123
          4        DO_FCALL                                      0  $0      
          5        SEND_VAR                                                 $0
          6        DO_ICALL                                                 
   57     7        INIT_FCALL                                               'var_dump'
          8        SEND_VAL                                                 1518435
          9        DO_ICALL                                                 
         10      > RETURN                                                   1

Function stringmultiplicate:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 75
Branch analysis from position: 75
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 12
Branch analysis from position: 77
1 jumps found. (Code = 42) Position 1 = 105
Branch analysis from position: 105
2 jumps found. (Code = 44) Position 1 = 107, Position 2 = 80
Branch analysis from position: 107
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 80
1 jumps found. (Code = 42) Position 1 = 99
Branch analysis from position: 99
2 jumps found. (Code = 44) Position 1 = 102, Position 2 = 83
Branch analysis from position: 102
2 jumps found. (Code = 44) Position 1 = 107, Position 2 = 80
Branch analysis from position: 107
Branch analysis from position: 80
Branch analysis from position: 83
2 jumps found. (Code = 43) Position 1 = 91, Position 2 = 94
Branch analysis from position: 91
2 jumps found. (Code = 44) Position 1 = 102, Position 2 = 83
Branch analysis from position: 102
Branch analysis from position: 83
Branch analysis from position: 94
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 60
Branch analysis from position: 60
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 27
Branch analysis from position: 62
2 jumps found. (Code = 43) Position 1 = 66, Position 2 = 68
Branch analysis from position: 66
2 jumps found. (Code = 44) Position 1 = 77, Position 2 = 12
Branch analysis from position: 77
Branch analysis from position: 12
Branch analysis from position: 68
Branch analysis from position: 27
1 jumps found. (Code = 42) Position 1 = 31
Branch analysis from position: 31
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 28
Branch analysis from position: 33
2 jumps found. (Code = 46) Position 1 = 40, Position 2 = 42
Branch analysis from position: 40
2 jumps found. (Code = 43) Position 1 = 43, Position 2 = 53
Branch analysis from position: 43
1 jumps found. (Code = 42) Position 1 = 59
Branch analysis from position: 59
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 27
Branch analysis from position: 62
Branch analysis from position: 27
Branch analysis from position: 53
2 jumps found. (Code = 44) Position 1 = 62, Position 2 = 27
Branch analysis from position: 62
Branch analysis from position: 27
Branch analysis from position: 42
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 33, Position 2 = 28
Branch analysis from position: 33
Branch analysis from position: 28
filename:       /in/c1drQ
function name:  stringMultiplicate
number of ops:  109
compiled vars:  !0 = $first, !1 = $second, !2 = $result, !3 = $strFirst, !4 = $strSecond, !5 = $maxLength, !6 = $i, !7 = $index, !8 = $number, !9 = $k, !10 = $div, !11 = $j, !12 = $next, !13 = $multi, !14 = $sum
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   RECV                                             !0      
          1        RECV                                             !1      
    5     2        ASSIGN                                                   !2, <array>
    6     3        CAST                                          6  ~16     !0
          4        ASSIGN                                                   !3, ~16
    7     5        CAST                                          6  ~18     !1
          6        ASSIGN                                                   !4, ~18
    9     7        ASSIGN                                                   !5, 0
   10     8        STRLEN                                           ~21     !4
          9        SUB                                              ~22     ~21, 1
         10        ASSIGN                                                   !6, ~22
         11      > JMP                                                      ->75
   11    12    >   ASSIGN                                                   !7, !6
   12    13        FETCH_DIM_R                                      ~25     !4, !6
         14        CAST                                          4  ~26     ~25
         15        ASSIGN                                                   !8, ~26
   13    16        ASSIGN_DIM                                               !2, !7
         17        OP_DATA                                                  ''
   15    18        STRLEN                                           ~29     !4
         19        SUB                                              ~30     ~29, 1
         20        SUB                                              ~31     ~30, !6
         21        ASSIGN                                                   !9, ~31
   16    22        ASSIGN                                                   !10, 0
   17    23        STRLEN                                           ~34     !3
         24        SUB                                              ~35     ~34, 1
         25        ASSIGN                                                   !11, ~35
         26      > JMP                                                      ->60
   18    27    > > JMP                                                      ->31
   19    28    >   ASSIGN_DIM_OP                .=               8          !2, !7
         29        OP_DATA                                                  '0'
   20    30        PRE_DEC                                                  !9
   18    31    >   IS_NOT_EQUAL                                             !9, 0
         32      > JMPNZ                                                    ~39, ->28
   23    33    >   FETCH_DIM_R                                      ~40     !3, !11
         34        MUL                                              ~41     !8, ~40
         35        ADD                                              ~42     ~41, !10
         36        ASSIGN                                                   !12, ~42
   24    37        STRLEN                                           ~44     !12
         38        IS_SMALLER                                       ~45     1, ~44
         39      > JMPZ_EX                                          ~45     ~45, ->42
         40    >   IS_NOT_EQUAL                                     ~46     !11, 0
         41        BOOL                                             ~45     ~46
         42    > > JMPZ                                                     ~45, ->53
   25    43    >   CAST                                          6  ~48     !12
         44        STRLEN                                           ~49     !12
         45        SUB                                              ~50     ~49, 1
         46        FETCH_DIM_R                                      ~51     ~48, ~50
         47        ASSIGN_DIM_OP                .=               8          !2, !7
         48        OP_DATA                                                  ~51
   26    49        CAST                                          6  ~52     !12
         50        FETCH_DIM_R                                      ~53     ~52, 0
         51        ASSIGN                                                   !10, ~53
         52      > JMP                                                      ->59
   29    53    >   FETCH_DIM_R                                      ~56     !3, !11
         54        MUL                                              ~57     !8, ~56
         55        ADD                                              ~58     ~57, !10
         56        ASSIGN_DIM_OP                .=               8          !2, !7
         57        OP_DATA                                                  ~58
   30    58        ASSIGN                                                   !10, 0
   17    59    >   PRE_DEC                                                  !11
         60    >   IS_SMALLER_OR_EQUAL                                      0, !11
         61      > JMPNZ                                                    ~61, ->27
   34    62    >   FETCH_DIM_R                                      ~62     !2, !7
         63        STRLEN                                           ~63     ~62
         64        IS_SMALLER                                               !5, ~63
         65      > JMPZ                                                     ~64, ->68
   35    66    >   FETCH_DIM_R                                      ~65     !2, !7
         67        ASSIGN                                                   !5, ~65
   38    68    >   INIT_FCALL                                               'strrev'
         69        FETCH_DIM_R                                      ~68     !2, !7
         70        SEND_VAL                                                 ~68
         71        DO_ICALL                                         $69     
         72        ASSIGN_DIM                                               !2, !7
         73        OP_DATA                                                  $69
   10    74        PRE_DEC                                                  !6
         75    >   IS_SMALLER_OR_EQUAL                                      0, !6
         76      > JMPNZ                                                    ~71, ->12
   41    77    >   ASSIGN                                                   !13, <array>
   42    78        ASSIGN                                                   !11, 0
         79      > JMP                                                      ->105
   43    80    >   ASSIGN                                                   !14, 0
   44    81        ASSIGN                                                   !6, 0
         82      > JMP                                                      ->99
   45    83    >   INIT_FCALL                                               'var_dump'
         84        FETCH_DIM_R                                      ~76     !2, !6
         85        SEND_VAL                                                 ~76
         86        DO_ICALL                                                 
   46    87        FETCH_DIM_IS                                     ~78     !2, !6
         88        ISSET_ISEMPTY_DIM_OBJ                         0  ~79     ~78, !11
         89        BOOL_NOT                                         ~80     ~79
         90      > JMPZ                                                     ~80, ->94
   47    91    >   FETCH_DIM_W                                      $81     !2, !6
         92        ASSIGN_DIM                                               $81, !11
         93        OP_DATA                                                  0
   49    94    >   FETCH_DIM_R                                      ~83     !2, !6
         95        FETCH_DIM_R                                      ~84     ~83, !11
         96        CAST                                          4  ~85     ~84
         97        ASSIGN_OP                                     1          !14, ~85
   44    98        PRE_INC                                                  !6
         99    >   COUNT                                            ~88     !2
        100        IS_SMALLER                                               !6, ~88
        101      > JMPNZ                                                    ~89, ->83
   51   102    >   ASSIGN_DIM                                               !13, !6
        103        OP_DATA                                                  !14
   42   104        PRE_INC                                                  !11
        105    >   IS_SMALLER                                               !11, !5
        106      > JMPNZ                                                    ~92, ->80
   53   107    > > RETURN                                                   !13
   54   108*     > RETURN                                                   null

End of function stringmultiplicate

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
152.21 ms | 1402 KiB | 18 Q