3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = [ [ 'name' => 'Фізика', 'disciplines' => [ 1 => 'Українська мова та література', 4 => 'Математика', 5 => 'Фізика', 6 => 'Біологія', ], 'priority' => [ 1 => 0, 4 => 1, 5 => 2, 6 => 2, ] ], [ 'name' => 'Інформатика', 'disciplines' => [ 1 => 'Українська мова та література', 2 => 'Історія України', 4 => 'Математика', 12 => 'Іноземна мова', ], 'priority' => [ 1 => 0, 2 => 2, 4 => 1, 12 => 2, ] ], [ 'name' => 'Початкова освіта', 'disciplines' => [ 1 => 'Українська мова та література', 2 => 'Історія України', ], 'priority' => [ 1 => 0, 2 => 2, ] ], ]; $get['disciplines'] = ['second' => 2, 'third' => 4, 'fourth' => 12]; $filterBy = array_flip($get['disciplines']); var_export( array_filter( $array, fn($row) => !array_diff_key($filterBy, $row['disciplines']) ) );
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hQT7R
function name:  (null)
number of ops:  18
compiled vars:  !0 = $array, !1 = $get, !2 = $filterBy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   47     1        ASSIGN_DIM                                               !1, 'disciplines'
          2        OP_DATA                                                  <array>
   48     3        INIT_FCALL                                               'array_flip'
          4        FETCH_DIM_R                                      ~5      !1, 'disciplines'
          5        SEND_VAL                                                 ~5
          6        DO_ICALL                                         $6      
          7        ASSIGN                                                   !2, $6
   50     8        INIT_FCALL                                               'var_export'
   51     9        INIT_FCALL                                               'array_filter'
   52    10        SEND_VAR                                                 !0
   53    11        DECLARE_LAMBDA_FUNCTION                          ~8      [0]
         12        BIND_LEXICAL                                             ~8, !2
   54    13        SEND_VAL                                                 ~8
   51    14        DO_ICALL                                         $9      
   54    15        SEND_VAR                                                 $9
   50    16        DO_ICALL                                                 
   55    17      > RETURN                                                   1


Dynamic Functions:
Dynamic Function 0
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hQT7R
function name:  {closure}
number of ops:  10
compiled vars:  !0 = $row, !1 = $filterBy
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   53     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
          2        INIT_FCALL                                               'array_diff_key'
          3        SEND_VAR                                                 !1
          4        FETCH_DIM_R                                      ~2      !0, 'disciplines'
          5        SEND_VAL                                                 ~2
          6        DO_ICALL                                         $3      
          7        BOOL_NOT                                         ~4      $3
          8      > RETURN                                                   ~4
   54     9*     > RETURN                                                   null

End of Dynamic Function 0

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
150.8 ms | 1014 KiB | 17 Q