3v4l.org

run code in 300+ PHP versions simultaneously
<?php $in = [ ['id' => 1, 'currency' => 'EUR', 'name' => 'NL'], ['id' => 2, 'currency' => 'EUR', 'name' => 'DE'], ['id' => 3, 'currency' => 'EUR', 'name' => 'FR'], ['id' => 4, 'currency' => 'EUR', 'name' => 'BE'], ['id' => 5, 'currency' => 'USD', 'name' => 'US'], ['id' => 6, 'currency' => 'Rand', 'name' => 'SAF'], ['id' => 7, 'currency' => 'Rubbles', 'name' => 'RUS'], ['id' => 8, 'currency' => 'EUR', 'name' => 'IT'], ['id' => 9, 'currency' => 'Pound', 'name' => 'GB'], ]; $query = ['currency' => 'EUR', 'id' => 8]; //search needles $out = array_filter($in, function(array $candidate) use ($query) { foreach ($query as $key => $predicate) { if (isset($candidate[$key]) && $candidate[$key] !== $predicate) { return false; } } return true; }); print_r($out);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/aAZPP
function name:  (null)
number of ops:  13
compiled vars:  !0 = $in, !1 = $query, !2 = $out
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   15     1        ASSIGN                                                   !1, <array>
   17     2        INIT_FCALL                                               'array_filter'
          3        SEND_VAR                                                 !0
          4        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FaAZPP%3A17%240'
          5        BIND_LEXICAL                                             ~5, !1
   26     6        SEND_VAL                                                 ~5
          7        DO_ICALL                                         $6      
   17     8        ASSIGN                                                   !2, $6
   28     9        INIT_FCALL                                               'print_r'
         10        SEND_VAR                                                 !2
         11        DO_ICALL                                                 
         12      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FaAZPP%3A17%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 3, Position 2 = 14
Branch analysis from position: 3
2 jumps found. (Code = 78) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 46) Position 1 = 7, Position 2 = 10
Branch analysis from position: 7
2 jumps found. (Code = 43) Position 1 = 11, Position 2 = 13
Branch analysis from position: 11
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 3
Branch analysis from position: 3
Branch analysis from position: 10
Branch analysis from position: 14
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 14
filename:       /in/aAZPP
function name:  {closure}
number of ops:  17
compiled vars:  !0 = $candidate, !1 = $query, !2 = $predicate, !3 = $key
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   17     0  E >   RECV                                             !0      
          1        BIND_STATIC                                              !1
   19     2      > FE_RESET_R                                       $4      !1, ->14
          3    > > FE_FETCH_R                                       ~5      $4, !2, ->14
          4    >   ASSIGN                                                   !3, ~5
   20     5        ISSET_ISEMPTY_DIM_OBJ                         0  ~7      !0, !3
          6      > JMPZ_EX                                          ~7      ~7, ->10
          7    >   FETCH_DIM_R                                      ~8      !0, !3
          8        IS_NOT_IDENTICAL                                 ~9      !2, ~8
          9        BOOL                                             ~7      ~9
         10    > > JMPZ                                                     ~7, ->13
   21    11    >   FE_FREE                                                  $4
         12      > RETURN                                                   <false>
   19    13    > > JMP                                                      ->3
         14    >   FE_FREE                                                  $4
   25    15      > RETURN                                                   <true>
   26    16*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FaAZPP%3A17%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
146.48 ms | 1396 KiB | 17 Q