3v4l.org

run code in 300+ PHP versions simultaneously
<?php $arr1 = ["101","206", "206"]; $arr2 = ["PA701", "PA700", "PA700"]; $arr3 = ["2022-04-01", "2022-04-07", "2022-04-07"]; $arr4 = [70, 1040, 1625]; //expected Result $res1 = ["101","206"]; $res2 = ["PA701", "PA700"]; $res3 = ["2022-04-01", "2022-04-07"]; $res4 = [70, 2665]; foreach($arr1 as $k=>$val) { if(isset($arr1[$k+1])) { if($arr1[$k] == $arr1[$k+1] && $arr2[$k] == $arr2[$k+1] && $arr3[$k] == $arr3[$k+1]) { unset($arr1[$k+1]); unset($arr2[$k+1]); unset($arr3[$k+1]); $arr4[$k] += $arr4[$k+1]; unset($arr4[$k+1]); } } } print_r($arr1); print_r($arr2); print_r($arr3); print_r($arr4);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 44
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 44
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 43
Branch analysis from position: 14
2 jumps found. (Code = 46) Position 1 = 19, Position 2 = 24
Branch analysis from position: 19
2 jumps found. (Code = 46) Position 1 = 25, Position 2 = 30
Branch analysis from position: 25
2 jumps found. (Code = 43) Position 1 = 31, Position 2 = 43
Branch analysis from position: 31
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 43
Branch analysis from position: 30
Branch analysis from position: 24
Branch analysis from position: 43
Branch analysis from position: 44
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 44
filename:       /in/kuOBh
function name:  (null)
number of ops:  58
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $arr3, !3 = $arr4, !4 = $res1, !5 = $res2, !6 = $res3, !7 = $res4, !8 = $val, !9 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3        ASSIGN                                                   !3, <array>
    9     4        ASSIGN                                                   !4, <array>
   10     5        ASSIGN                                                   !5, <array>
   11     6        ASSIGN                                                   !6, <array>
   12     7        ASSIGN                                                   !7, <array>
   14     8      > FE_RESET_R                                       $18     !0, ->44
          9    > > FE_FETCH_R                                       ~19     $18, !8, ->44
         10    >   ASSIGN                                                   !9, ~19
   16    11        ADD                                              ~21     !9, 1
         12        ISSET_ISEMPTY_DIM_OBJ                         0          !0, ~21
         13      > JMPZ                                                     ~22, ->43
   18    14    >   FETCH_DIM_R                                      ~23     !0, !9
         15        ADD                                              ~24     !9, 1
         16        FETCH_DIM_R                                      ~25     !0, ~24
         17        IS_EQUAL                                         ~26     ~23, ~25
         18      > JMPZ_EX                                          ~26     ~26, ->24
         19    >   FETCH_DIM_R                                      ~27     !1, !9
         20        ADD                                              ~28     !9, 1
         21        FETCH_DIM_R                                      ~29     !1, ~28
         22        IS_EQUAL                                         ~30     ~27, ~29
         23        BOOL                                             ~26     ~30
         24    > > JMPZ_EX                                          ~26     ~26, ->30
         25    >   FETCH_DIM_R                                      ~31     !2, !9
         26        ADD                                              ~32     !9, 1
         27        FETCH_DIM_R                                      ~33     !2, ~32
         28        IS_EQUAL                                         ~34     ~31, ~33
         29        BOOL                                             ~26     ~34
         30    > > JMPZ                                                     ~26, ->43
   20    31    >   ADD                                              ~35     !9, 1
         32        UNSET_DIM                                                !0, ~35
   21    33        ADD                                              ~36     !9, 1
         34        UNSET_DIM                                                !1, ~36
   22    35        ADD                                              ~37     !9, 1
         36        UNSET_DIM                                                !2, ~37
   23    37        ADD                                              ~39     !9, 1
         38        FETCH_DIM_R                                      ~40     !3, ~39
         39        ASSIGN_DIM_OP                +=               1          !3, !9
         40        OP_DATA                                                  ~40
   24    41        ADD                                              ~41     !9, 1
         42        UNSET_DIM                                                !3, ~41
   14    43    > > JMP                                                      ->9
         44    >   FE_FREE                                                  $18
   29    45        INIT_FCALL                                               'print_r'
         46        SEND_VAR                                                 !0
         47        DO_ICALL                                                 
   30    48        INIT_FCALL                                               'print_r'
         49        SEND_VAR                                                 !1
         50        DO_ICALL                                                 
   31    51        INIT_FCALL                                               'print_r'
         52        SEND_VAR                                                 !2
         53        DO_ICALL                                                 
   32    54        INIT_FCALL                                               'print_r'
         55        SEND_VAR                                                 !3
         56        DO_ICALL                                                 
         57      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.69 ms | 1002 KiB | 14 Q