3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = Array ( 0 => Array ( 'member_id' => 6, 'total' => 1, 'sorting' => 0 ), 1 => Array ( 'member_id' => 7, 'total' => 2, 'sorting' => 1 ) ); $b = Array ( 0 => Array ( 'member_id' => 2, 'total' => 3 ), 1 => Array ( 'member_id' => 6, 'total' => 1 ), 2 => Array ( 'member_id' => 7, 'total' => 2 ) ); $new_array = []; foreach ($a as $key => $data) { $new_array[$key]['member_id'] = $data['member_id']; foreach ($b as $key_1 => $data_1) { if ($data['member_id'] == $data_1['member_id']) { $new_array[$key]['total'] = $data_1['total']; if (isset($data_1['sorting'])) { $new_array[$key]['sorting'] = $data_1['sorting']; } else { $new_array[$key]['sorting'] = $data['sorting']; } break; } else { $new_array[$key]['total'] = 0; $new_array[$key]['sorting'] = $data['sorting']; } } } $new_array1 = []; foreach ($b as $key => $data) { if ($data['member_id'] != isset($new_array[$key]['member_id'])) { $new_array1[$key]['member_id'] = $data['member_id']; $new_array1[$key]['total'] = $data['total']; if (!isset($data['sorting'])) { $new_array1[$key]['sorting'] = isset($new_array[$key]['sorting']) ? $new_array[$key]['sorting'] + 1 : "" ; } } } $array_merge = array_merge($new_array, $new_array1); print_r($array_merge);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 44
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 44
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 42
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 42
Branch analysis from position: 12
2 jumps found. (Code = 43) Position 1 = 17, Position 2 = 34
Branch analysis from position: 17
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 28
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 42
Branch analysis from position: 42
Branch analysis from position: 34
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 42
Branch analysis from position: 42
Branch analysis from position: 44
2 jumps found. (Code = 77) Position 1 = 47, Position 2 = 78
Branch analysis from position: 47
2 jumps found. (Code = 78) Position 1 = 48, Position 2 = 78
Branch analysis from position: 48
2 jumps found. (Code = 43) Position 1 = 54, Position 2 = 77
Branch analysis from position: 54
2 jumps found. (Code = 43) Position 1 = 65, Position 2 = 77
Branch analysis from position: 65
2 jumps found. (Code = 43) Position 1 = 68, Position 2 = 73
Branch analysis from position: 68
1 jumps found. (Code = 42) Position 1 = 74
Branch analysis from position: 74
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 73
1 jumps found. (Code = 42) Position 1 = 47
Branch analysis from position: 47
Branch analysis from position: 77
Branch analysis from position: 77
Branch analysis from position: 78
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 78
Branch analysis from position: 44
filename:       /in/WBLCC
function name:  (null)
number of ops:  88
compiled vars:  !0 = $a, !1 = $b, !2 = $new_array, !3 = $data, !4 = $key, !5 = $data_1, !6 = $key_1, !7 = $new_array1, !8 = $array_merge
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, <array>
   41     2        ASSIGN                                                   !2, <array>
   42     3      > FE_RESET_R                                       $12     !0, ->44
          4    > > FE_FETCH_R                                       ~13     $12, !3, ->44
          5    >   ASSIGN                                                   !4, ~13
   43     6        FETCH_DIM_R                                      ~17     !3, 'member_id'
          7        FETCH_DIM_W                                      $15     !2, !4
          8        ASSIGN_DIM                                               $15, 'member_id'
          9        OP_DATA                                                  ~17
   44    10      > FE_RESET_R                                       $18     !1, ->42
         11    > > FE_FETCH_R                                       ~19     $18, !5, ->42
         12    >   ASSIGN                                                   !6, ~19
   45    13        FETCH_DIM_R                                      ~21     !3, 'member_id'
         14        FETCH_DIM_R                                      ~22     !5, 'member_id'
         15        IS_EQUAL                                                 ~21, ~22
         16      > JMPZ                                                     ~23, ->34
   46    17    >   FETCH_DIM_R                                      ~26     !5, 'total'
         18        FETCH_DIM_W                                      $24     !2, !4
         19        ASSIGN_DIM                                               $24, 'total'
         20        OP_DATA                                                  ~26
   47    21        ISSET_ISEMPTY_DIM_OBJ                         0          !5, 'sorting'
         22      > JMPZ                                                     ~27, ->28
   48    23    >   FETCH_DIM_R                                      ~30     !5, 'sorting'
         24        FETCH_DIM_W                                      $28     !2, !4
         25        ASSIGN_DIM                                               $28, 'sorting'
         26        OP_DATA                                                  ~30
   47    27      > JMP                                                      ->32
   50    28    >   FETCH_DIM_R                                      ~33     !3, 'sorting'
         29        FETCH_DIM_W                                      $31     !2, !4
         30        ASSIGN_DIM                                               $31, 'sorting'
         31        OP_DATA                                                  ~33
   52    32    > > JMP                                                      ->42
   45    33*       JMP                                                      ->41
   54    34    >   FETCH_DIM_W                                      $34     !2, !4
         35        ASSIGN_DIM                                               $34, 'total'
         36        OP_DATA                                                  0
   55    37        FETCH_DIM_R                                      ~38     !3, 'sorting'
         38        FETCH_DIM_W                                      $36     !2, !4
         39        ASSIGN_DIM                                               $36, 'sorting'
         40        OP_DATA                                                  ~38
   44    41      > JMP                                                      ->11
         42    >   FE_FREE                                                  $18
   42    43      > JMP                                                      ->4
         44    >   FE_FREE                                                  $12
   61    45        ASSIGN                                                   !7, <array>
   62    46      > FE_RESET_R                                       $40     !1, ->78
         47    > > FE_FETCH_R                                       ~41     $40, !3, ->78
         48    >   ASSIGN                                                   !4, ~41
   63    49        FETCH_DIM_R                                      ~43     !3, 'member_id'
         50        FETCH_DIM_IS                                     ~44     !2, !4
         51        ISSET_ISEMPTY_DIM_OBJ                         0  ~45     ~44, 'member_id'
         52        IS_NOT_EQUAL                                             ~43, ~45
         53      > JMPZ                                                     ~46, ->77
   64    54    >   FETCH_DIM_R                                      ~49     !3, 'member_id'
         55        FETCH_DIM_W                                      $47     !7, !4
         56        ASSIGN_DIM                                               $47, 'member_id'
         57        OP_DATA                                                  ~49
   65    58        FETCH_DIM_R                                      ~52     !3, 'total'
         59        FETCH_DIM_W                                      $50     !7, !4
         60        ASSIGN_DIM                                               $50, 'total'
         61        OP_DATA                                                  ~52
   66    62        ISSET_ISEMPTY_DIM_OBJ                         0  ~53     !3, 'sorting'
         63        BOOL_NOT                                         ~54     ~53
         64      > JMPZ                                                     ~54, ->77
   67    65    >   FETCH_DIM_IS                                     ~57     !2, !4
         66        ISSET_ISEMPTY_DIM_OBJ                         0          ~57, 'sorting'
         67      > JMPZ                                                     ~58, ->73
         68    >   FETCH_DIM_R                                      ~59     !2, !4
         69        FETCH_DIM_R                                      ~60     ~59, 'sorting'
         70        ADD                                              ~61     ~60, 1
         71        QM_ASSIGN                                        ~62     ~61
         72      > JMP                                                      ->74
         73    >   QM_ASSIGN                                        ~62     ''
         74    >   FETCH_DIM_W                                      $55     !7, !4
         75        ASSIGN_DIM                                               $55, 'sorting'
         76        OP_DATA                                                  ~62
   62    77    > > JMP                                                      ->47
         78    >   FE_FREE                                                  $40
   72    79        INIT_FCALL                                               'array_merge'
         80        SEND_VAR                                                 !2
         81        SEND_VAR                                                 !7
         82        DO_ICALL                                         $63     
         83        ASSIGN                                                   !8, $63
   74    84        INIT_FCALL                                               'print_r'
         85        SEND_VAR                                                 !8
         86        DO_ICALL                                                 
         87      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
140.98 ms | 962 KiB | 15 Q