3v4l.org

run code in 500+ PHP versions simultaneously
<?php $a = array( 0 => 2, 1 => 3, 2 => 10, 3 => 3, 4 => 4, 5 => 8, 6 => 5, 7 => 1, 8 => 1 ); $b = array( 0 => "Hello world poduct", 1 => "Test Product", 2 => "Hello world poduct", 3 => "Hello world poduct", 4 => "Test Product", 5 => "Test Product", 6 => "Test Product", 7 => "Test Product", 8 => "Test Product", ); #for usage $result = []; for($i=0;$i<count($a);$i++){ if(!isset($result[$b[$i]])){ $result[$b[$i]] = 0; } $result[$b[$i]] += $a[$i]; } var_export($result); #array_walk $result = []; array_walk($a,function($v,$i) use (&$result,$b) { if(!isset($result[$b[$i]])){ $result[$b[$i]] = 0; } $result[$b[$i]] += $v; }); echo PHP_EOL; var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 17
Branch analysis from position: 17
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 9, Position 2 = 12
Branch analysis from position: 9
2 jumps found. (Code = 44) Position 1 = 20, Position 2 = 5
Branch analysis from position: 20
Branch analysis from position: 5
Branch analysis from position: 12
filename:       /in/Fh5Xj
function name:  (null)
number of ops:  36
compiled vars:  !0 = $a, !1 = $b, !2 = $result, !3 = $i
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   15     1        ASSIGN                                                       !1, <array>
   29     2        ASSIGN                                                       !2, <array>
   30     3        ASSIGN                                                       !3, 0
          4      > JMP                                                          ->17
   31     5    >   FETCH_DIM_R                                          ~8      !1, !3
          6        ISSET_ISEMPTY_DIM_OBJ                             0  ~9      !2, ~8
          7        BOOL_NOT                                             ~10     ~9
          8      > JMPZ                                                         ~10, ->12
   32     9    >   FETCH_DIM_R                                          ~11     !1, !3
         10        ASSIGN_DIM                                                   !2, ~11
         11        OP_DATA                                                      0
   34    12    >   FETCH_DIM_R                                          ~13     !1, !3
         13        FETCH_DIM_R                                          ~15     !0, !3
         14        ASSIGN_DIM_OP                    +=               1          !2, ~13
         15        OP_DATA                                                      ~15
   30    16        PRE_INC                                                      !3
         17    >   COUNT                                                ~17     !0
         18        IS_SMALLER                                                   !3, ~17
         19      > JMPNZ                                                        ~18, ->5
   36    20    >   INIT_FCALL                                                   'var_export'
         21        SEND_VAR                                                     !2
         22        DO_ICALL                                                     
   39    23        ASSIGN                                                       !2, <array>
   40    24        INIT_FCALL                                                   'array_walk'
         25        SEND_REF                                                     !0
         26        DECLARE_LAMBDA_FUNCTION                              ~21     [0]
         27        BIND_LEXICAL                                                 ~21, !2
         28        BIND_LEXICAL                                                 ~21, !1
   45    29        SEND_VAL                                                     ~21
   40    30        DO_ICALL                                                     
   46    31        ECHO                                                         '%0A'
   47    32        INIT_FCALL                                                   'var_export'
         33        SEND_VAR                                                     !2
         34        DO_ICALL                                                     
         35      > RETURN                                                       1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 8, Position 2 = 11
Branch analysis from position: 8
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
filename:       /in/Fh5Xj
function name:  {closure:/in/Fh5Xj:40}
number of ops:  15
compiled vars:  !0 = $v, !1 = $i, !2 = $result, !3 = $b
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
   40     0  E >   RECV                                                 !0      
          1        RECV                                                 !1      
          2        BIND_STATIC                                                  !2
          3        BIND_STATIC                                                  !3
   41     4        FETCH_DIM_R                                          ~4      !3, !1
          5        ISSET_ISEMPTY_DIM_OBJ                             0  ~5      !2, ~4
          6        BOOL_NOT                                             ~6      ~5
          7      > JMPZ                                                         ~6, ->11
   42     8    >   FETCH_DIM_R                                          ~7      !3, !1
          9        ASSIGN_DIM                                                   !2, ~7
         10        OP_DATA                                                      0
   44    11    >   FETCH_DIM_R                                          ~9      !3, !1
         12        ASSIGN_DIM_OP                    +=               1          !2, ~9
         13        OP_DATA                                                      !0
   45    14      > RETURN                                                       null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.34 ms | 1733 KiB | 15 Q