3v4l.org

run code in 300+ PHP versions simultaneously
<?php $insertData = [ ['prid' => 4, 'vendor_id' => 1], ['prid' => 5, 'vendor_id' => 2], ]; $requestData = [ 'vendor_id' => [1, 1, 2, 2], 'item' => [2, 3, 4, 5], 'qty' => [12, 13, 14, 15] ]; $insertLookup = array_column($insertData, 'prid', 'vendor_id'); $result = []; foreach ($requestData['vendor_id'] as $index => $vendorId) { $result[] = [ 'prid' => $insertLookup[$vendorId], 'vendor_id' => $vendorId, 'item' => $requestData['item'][$index], 'qty' => $requestData['qty'][$index], ]; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 11, Position 2 = 25
Branch analysis from position: 11
2 jumps found. (Code = 78) Position 1 = 12, Position 2 = 25
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 11
Branch analysis from position: 11
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
filename:       /in/0GorL
function name:  (null)
number of ops:  30
compiled vars:  !0 = $insertData, !1 = $requestData, !2 = $insertLookup, !3 = $result, !4 = $vendorId, !5 = $index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    8     1        ASSIGN                                                   !1, <array>
   14     2        INIT_FCALL                                               'array_column'
          3        SEND_VAR                                                 !0
          4        SEND_VAL                                                 'prid'
          5        SEND_VAL                                                 'vendor_id'
          6        DO_ICALL                                         $8      
          7        ASSIGN                                                   !2, $8
   15     8        ASSIGN                                                   !3, <array>
   16     9        FETCH_DIM_R                                      ~11     !1, 'vendor_id'
         10      > FE_RESET_R                                       $12     ~11, ->25
         11    > > FE_FETCH_R                                       ~13     $12, !4, ->25
         12    >   ASSIGN                                                   !5, ~13
   18    13        FETCH_DIM_R                                      ~16     !2, !4
         14        INIT_ARRAY                                       ~17     ~16, 'prid'
   19    15        ADD_ARRAY_ELEMENT                                ~17     !4, 'vendor_id'
   20    16        FETCH_DIM_R                                      ~18     !1, 'item'
         17        FETCH_DIM_R                                      ~19     ~18, !5
         18        ADD_ARRAY_ELEMENT                                ~17     ~19, 'item'
   21    19        FETCH_DIM_R                                      ~20     !1, 'qty'
         20        FETCH_DIM_R                                      ~21     ~20, !5
         21        ADD_ARRAY_ELEMENT                                ~17     ~21, 'qty'
   17    22        ASSIGN_DIM                                               !3
   21    23        OP_DATA                                                  ~17
   16    24      > JMP                                                      ->11
         25    >   FE_FREE                                                  $12
   24    26        INIT_FCALL                                               'var_export'
         27        SEND_VAR                                                 !3
         28        DO_ICALL                                                 
         29      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
143.2 ms | 1004 KiB | 15 Q