3v4l.org

run code in 300+ PHP versions simultaneously
<?php $taxonomies = [ 'genres' => [ 'label' => 'Genres', 'value' => 'genres' ], 'somethingelse' => [ 'label' => 'foo', 'value' => 'bar' ], 'movie_tags' => [ 'label' => 'Movie Tags', 'value' => 'movie_tags' ], 'portfolio_category' => [ 'label' => 'Portfolio Categories', 'value' => 'portfolio_category' ] ]; $postTypes = [ 'movies' => ['genres', 'movie_tags'], 'portfolio' => ['portfolio_category'], ]; $result = []; foreach ($postTypes as $group => $taxKeys) { $result[$group] = array_values( array_intersect_key( $taxonomies, array_flip($taxKeys) ) ); } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 19
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 19
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 19
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 19
filename:       /in/YtQ1M
function name:  (null)
number of ops:  24
compiled vars:  !0 = $taxonomies, !1 = $postTypes, !2 = $result, !3 = $taxKeys, !4 = $group
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        ASSIGN                                                   !1, <array>
   27     2        ASSIGN                                                   !2, <array>
   28     3      > FE_RESET_R                                       $8      !1, ->19
          4    > > FE_FETCH_R                                       ~9      $8, !3, ->19
          5    >   ASSIGN                                                   !4, ~9
   29     6        INIT_FCALL                                               'array_values'
   30     7        INIT_FCALL                                               'array_intersect_key'
   31     8        SEND_VAR                                                 !0
   32     9        INIT_FCALL                                               'array_flip'
         10        SEND_VAR                                                 !3
         11        DO_ICALL                                         $12     
         12        SEND_VAR                                                 $12
   30    13        DO_ICALL                                         $13     
   32    14        SEND_VAR                                                 $13
   29    15        DO_ICALL                                         $14     
         16        ASSIGN_DIM                                               !2, !4
   32    17        OP_DATA                                                  $14
   28    18      > JMP                                                      ->4
         19    >   FE_FREE                                                  $8
   36    20        INIT_FCALL                                               'var_export'
         21        SEND_VAR                                                 !2
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
138 ms | 1001 KiB | 17 Q