3v4l.org

run code in 300+ PHP versions simultaneously
<?php $original = [ 1=>[ 1=>['brand'=> 'bmw' , 'color'=> 'white'], 171=>['brand'=> 'audi' , 'color'=> 'black'], 172=>['brand'=> 'volvo' , 'color'=> 'black'], 175=>['brand'=> 'citroen' , 'color'=> 'green'] ], 129=>[ 201=>['brand'=> 'volkswagen' , 'color'=> 'grey'], 206=>['brand'=> 'bentley' , 'color'=> 'grey'], 209=>['brand'=> 'mazda' , 'color'=> 'blue'], ], ]; $filterOnArray = [172,175,209]; $finalArray = []; foreach($original as $key=>$orig ){ $nonfiter =$orig; foreach($filterOnArray as $filterOnArr){ if(isset($orig[$filterOnArr])){ $finalArray[$key][$filterOnArr] = $orig[$filterOnArr]; unset($nonfiter[$filterOnArr]); } } $finalArray[$key] = $finalArray[$key] +$nonfiter; } print_r($finalArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 23
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 23
Branch analysis from position: 5
2 jumps found. (Code = 77) Position 1 = 8, Position 2 = 17
Branch analysis from position: 8
2 jumps found. (Code = 78) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 16
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 8
Branch analysis from position: 8
Branch analysis from position: 16
Branch analysis from position: 17
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 17
Branch analysis from position: 23
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 23
filename:       /in/BmZmj
function name:  (null)
number of ops:  28
compiled vars:  !0 = $original, !1 = $filterOnArray, !2 = $finalArray, !3 = $orig, !4 = $key, !5 = $nonfiter, !6 = $filterOnArr
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   17     1        ASSIGN                                                   !1, <array>
   20     2        ASSIGN                                                   !2, <array>
   23     3      > FE_RESET_R                                       $10     !0, ->23
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->23
          5    >   ASSIGN                                                   !4, ~11
   24     6        ASSIGN                                                   !5, !3
   25     7      > FE_RESET_R                                       $14     !1, ->17
          8    > > FE_FETCH_R                                               $14, !6, ->17
   26     9    >   ISSET_ISEMPTY_DIM_OBJ                         0          !3, !6
         10      > JMPZ                                                     ~15, ->16
   27    11    >   FETCH_DIM_R                                      ~18     !3, !6
         12        FETCH_DIM_W                                      $16     !2, !4
         13        ASSIGN_DIM                                               $16, !6
         14        OP_DATA                                                  ~18
   28    15        UNSET_DIM                                                !5, !6
   25    16    > > JMP                                                      ->8
         17    >   FE_FREE                                                  $14
   31    18        FETCH_DIM_R                                      ~20     !2, !4
         19        ADD                                              ~21     ~20, !5
         20        ASSIGN_DIM                                               !2, !4
         21        OP_DATA                                                  ~21
   23    22      > JMP                                                      ->4
         23    >   FE_FREE                                                  $10
   34    24        INIT_FCALL                                               'print_r'
         25        SEND_VAR                                                 !2
         26        DO_ICALL                                                 
         27      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138.83 ms | 1068 KiB | 14 Q