3v4l.org

run code in 300+ PHP versions simultaneously
<?php $mapped = [ [ 'key1' => false, ], [ 'key2' => 'value', ], ]; $flatMapped = array_filter(array_merge(...$mapped)); print_r($flatMapped); $csvData = [ [ 'key1' => 42, 'key2' => 142, 'key3' => 242, ], [ 'key1' => 342, 'key2' => 442, 'key3' => 542, ], ]; $newData = []; foreach ($csvData as &$item) { $item = array_intersect_key($item, $flatMapped); } print_r($csvData);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 125) Position 1 = 15, Position 2 = 22
Branch analysis from position: 15
2 jumps found. (Code = 126) Position 1 = 16, Position 2 = 22
Branch analysis from position: 16
1 jumps found. (Code = 42) Position 1 = 15
Branch analysis from position: 15
Branch analysis from position: 22
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 22
filename:       /in/0fAH4
function name:  (null)
number of ops:  27
compiled vars:  !0 = $mapped, !1 = $flatMapped, !2 = $csvData, !3 = $newData, !4 = $item
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   12     1        INIT_FCALL                                               'array_filter'
          2        INIT_FCALL                                               'array_merge'
          3        SEND_UNPACK                                              !0
          4        CHECK_UNDEF_ARGS                                         
          5        DO_ICALL                                         $6      
          6        SEND_VAR                                                 $6
          7        DO_ICALL                                         $7      
          8        ASSIGN                                                   !1, $7
   14     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !1
         11        DO_ICALL                                                 
   16    12        ASSIGN                                                   !2, <array>
   28    13        ASSIGN                                                   !3, <array>
   31    14      > FE_RESET_RW                                      $12     !2, ->22
         15    > > FE_FETCH_RW                                              $12, !4, ->22
   32    16    >   INIT_FCALL                                               'array_intersect_key'
         17        SEND_VAR                                                 !4
         18        SEND_VAR                                                 !1
         19        DO_ICALL                                         $13     
         20        ASSIGN                                                   !4, $13
   31    21      > JMP                                                      ->15
         22    >   FE_FREE                                                  $12
   34    23        INIT_FCALL                                               'print_r'
         24        SEND_VAR                                                 !2
         25        DO_ICALL                                                 
         26      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.82 ms | 1013 KiB | 17 Q