3v4l.org

run code in 300+ PHP versions simultaneously
<?php $saved_royalties = [ [ 'gross_total' => 1.797, 'track_name' => 'Desert Dance', 'transaction_type' => 'S' ], [ 'gross_total' => 0.0678, 'track_name' => 'Memphis City Of Kings', 'transaction_type' => 'AS' ], [ 'gross_total' => 0.023, 'track_name' => 'North African Market', 'transaction_type' => 'MT' ], [ 'gross_total' => 0.1173, 'track_name' => 'The Oracle', 'transaction_type' => 'CL' ] ]; $matching_royalty_rows = [ [ 'gross_total' => 2.435174, 'track_name' => 'Desert Dance', 'transaction_type' => 'S' ], [ 'gross_total' => 0.336815, 'track_name' => 'Memphis City Of Kings', 'transaction_type' => 'AS' ], [ 'gross_total' => 0.214106, 'track_name' => 'The Oracle', 'transaction_type' => 'CL' ] ]; $lookup = array_column($matching_royalty_rows, null, 'track_name'); $combined_rows = []; foreach ($saved_royalties as $row) { if (isset($lookup[$row['track_name']])) { $row = $lookup[$row['track_name']]; } else { $row['gross_total'] = 0; } $combined_rows[] = $row; } var_export($combined_rows);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 10, Position 2 = 23
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 23
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 14, Position 2 = 18
Branch analysis from position: 14
1 jumps found. (Code = 42) Position 1 = 20
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/t4MaX
function name:  (null)
number of ops:  28
compiled vars:  !0 = $saved_royalties, !1 = $matching_royalty_rows, !2 = $lookup, !3 = $combined_rows, !4 = $row
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   26     1        ASSIGN                                                   !1, <array>
   44     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !1
          4        SEND_VAL                                                 null
          5        SEND_VAL                                                 'track_name'
          6        DO_ICALL                                         $7      
          7        ASSIGN                                                   !2, $7
   46     8        ASSIGN                                                   !3, <array>
   47     9      > FE_RESET_R                                       $10     !0, ->23
         10    > > FE_FETCH_R                                               $10, !4, ->23
   48    11    >   FETCH_DIM_R                                      ~11     !4, 'track_name'
         12        ISSET_ISEMPTY_DIM_OBJ                         0          !2, ~11
         13      > JMPZ                                                     ~12, ->18
   49    14    >   FETCH_DIM_R                                      ~13     !4, 'track_name'
         15        FETCH_DIM_R                                      ~14     !2, ~13
         16        ASSIGN                                                   !4, ~14
   48    17      > JMP                                                      ->20
   51    18    >   ASSIGN_DIM                                               !4, 'gross_total'
         19        OP_DATA                                                  0
   53    20    >   ASSIGN_DIM                                               !3
         21        OP_DATA                                                  !4
   47    22      > JMP                                                      ->10
         23    >   FE_FREE                                                  $10
   55    24        INIT_FCALL                                               'var_export'
         25        SEND_VAR                                                 !3
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
151.14 ms | 1012 KiB | 15 Q