3v4l.org

run code in 300+ PHP versions simultaneously
<?php $left = Array ( 0 => Array ( 'UserID' => 6835406 ), 1 => Array ( 'UserID' => 8418097 ), 2 => Array ( 'UserID' => 9889987 ), 3 => Array ( 'UserID' => 9899999 ) ); $right = Array ( 0 => Array ( 'Amount' => 0.00, 'UserID' => 6835406 ), 1 => Array ( 'Amount' => 0.00, 'UserID' => 8418097 ), 2 => Array ( 'UserID' => 9889987 ) ); function combineArray($left, $right){ $finalArray = array(); foreach($left as $lft){ foreach($right as $rgt){ if($lft['UserID'] == $rgt['UserID']){ $finalArray[$lft['UserID']]['UserID'] = $lft['UserID']; $finalArray[$lft['UserID']]['Amount'] = (isset($rgt['Amount']) ? $rgt['Amount'] : NULL); break; }else{ $finalArray[$lft['UserID']]['UserID'] = $lft['UserID']; $finalArray[$lft['UserID']]['Amount'] = NULL; } } } return $finalArray = array_values($finalArray); } var_dump(combineArray($left, $right));
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aLWij
function name:  (null)
number of ops:  10
compiled vars:  !0 = $left, !1 = $right
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   25     1        ASSIGN                                                   !1, <array>
   62     2        INIT_FCALL                                               'var_dump'
          3        INIT_FCALL                                               'combinearray'
          4        SEND_VAR                                                 !0
          5        SEND_VAR                                                 !1
          6        DO_FCALL                                      0  $4      
          7        SEND_VAR                                                 $4
          8        DO_ICALL                                                 
          9      > RETURN                                                   1

Function combinearray:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 40
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 40
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 38
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 38
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 28
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 19, Position 2 = 22
Branch analysis from position: 19
1 jumps found. (Code = 42) Position 1 = 23
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 22
1 jumps found. (Code = 42) Position 1 = 38
Branch analysis from position: 38
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 38
Branch analysis from position: 38
Branch analysis from position: 40
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 40
filename:       /in/aLWij
function name:  combineArray
number of ops:  47
compiled vars:  !0 = $left, !1 = $right, !2 = $finalArray, !3 = $lft, !4 = $rgt
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   45     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   46     2        ASSIGN                                                   !2, <array>
   47     3      > FE_RESET_R                                       $6      !0, ->40
          4    > > FE_FETCH_R                                               $6, !3, ->40
   48     5    > > FE_RESET_R                                       $7      !1, ->38
          6    > > FE_FETCH_R                                               $7, !4, ->38
   49     7    >   FETCH_DIM_R                                      ~8      !3, 'UserID'
          8        FETCH_DIM_R                                      ~9      !4, 'UserID'
          9        IS_EQUAL                                                 ~8, ~9
         10      > JMPZ                                                     ~10, ->28
   50    11    >   FETCH_DIM_R                                      ~11     !3, 'UserID'
         12        FETCH_DIM_R                                      ~14     !3, 'UserID'
         13        FETCH_DIM_W                                      $12     !2, ~11
         14        ASSIGN_DIM                                               $12, 'UserID'
         15        OP_DATA                                                  ~14
   51    16        FETCH_DIM_R                                      ~15     !3, 'UserID'
         17        ISSET_ISEMPTY_DIM_OBJ                         0          !4, 'Amount'
         18      > JMPZ                                                     ~18, ->22
         19    >   FETCH_DIM_R                                      ~19     !4, 'Amount'
         20        QM_ASSIGN                                        ~20     ~19
         21      > JMP                                                      ->23
         22    >   QM_ASSIGN                                        ~20     null
         23    >   FETCH_DIM_W                                      $16     !2, ~15
         24        ASSIGN_DIM                                               $16, 'Amount'
         25        OP_DATA                                                  ~20
   52    26      > JMP                                                      ->38
   49    27*       JMP                                                      ->37
   54    28    >   FETCH_DIM_R                                      ~21     !3, 'UserID'
         29        FETCH_DIM_R                                      ~24     !3, 'UserID'
         30        FETCH_DIM_W                                      $22     !2, ~21
         31        ASSIGN_DIM                                               $22, 'UserID'
         32        OP_DATA                                                  ~24
   55    33        FETCH_DIM_R                                      ~25     !3, 'UserID'
         34        FETCH_DIM_W                                      $26     !2, ~25
         35        ASSIGN_DIM                                               $26, 'Amount'
         36        OP_DATA                                                  null
   48    37      > JMP                                                      ->6
         38    >   FE_FREE                                                  $7
   47    39      > JMP                                                      ->4
         40    >   FE_FREE                                                  $6
   59    41        INIT_FCALL                                               'array_values'
         42        SEND_VAR                                                 !2
         43        DO_ICALL                                         $28     
         44        ASSIGN                                           ~29     !2, $28
         45      > RETURN                                                   ~29
   60    46*     > RETURN                                                   null

End of function combinearray

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.49 ms | 1006 KiB | 16 Q