3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array( array( 'Field1' => 'red', 'Field2' => 'green', 'Field3' => 'blue' ), array( 'Field1' => 'pink', 'Field2' => 'pinkish', 'Field3' => 'barbiecolor' ), array( 'Field1' => 'red', 'Field2' => 'blue', ' Field3' => 'orange' ) ); $searchBy = array( 'Field1' => 'red', 'Field2' => 'blue' ); // use($searchBy) function find($needle, $haystack) { $r = array(); foreach ( $haystack as $k => $a ) { array_intersect_assoc($needle, $a) == $needle and $r[$k] = $a; } return $r; } $find = find($searchBy, $array); print_r($find); ?>
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/eBgXc
function name:  (null)
number of ops:  11
compiled vars:  !0 = $array, !1 = $searchBy, !2 = $find
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   19     1        ASSIGN                                                   !1, <array>
   32     2        INIT_FCALL                                               'find'
          3        SEND_VAR                                                 !1
          4        SEND_VAR                                                 !0
          5        DO_FCALL                                      0  $5      
          6        ASSIGN                                                   !2, $5
   34     7        INIT_FCALL                                               'print_r'
          8        SEND_VAR                                                 !2
          9        DO_ICALL                                                 
   36    10      > RETURN                                                   1

Function find:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 16
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 16
Branch analysis from position: 5
2 jumps found. (Code = 46) Position 1 = 12, Position 2 = 15
Branch analysis from position: 12
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 15
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/eBgXc
function name:  find
number of ops:  19
compiled vars:  !0 = $needle, !1 = $haystack, !2 = $r, !3 = $a, !4 = $k
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   25     0  E >   RECV                                             !0      
          1        RECV                                             !1      
   26     2        ASSIGN                                                   !2, <array>
   27     3      > FE_RESET_R                                       $6      !1, ->16
          4    > > FE_FETCH_R                                       ~7      $6, !3, ->16
          5    >   ASSIGN                                                   !4, ~7
   28     6        INIT_FCALL                                               'array_intersect_assoc'
          7        SEND_VAR                                                 !0
          8        SEND_VAR                                                 !3
          9        DO_ICALL                                         $9      
         10        IS_EQUAL                                         ~10     !0, $9
         11      > JMPZ_EX                                          ~10     ~10, ->15
         12    >   ASSIGN_DIM                                       ~11     !2, !4
         13        OP_DATA                                                  !3
         14        BOOL                                             ~10     ~11
   27    15    > > JMP                                                      ->4
         16    >   FE_FREE                                                  $6
   30    17      > RETURN                                                   !2
   31    18*     > RETURN                                                   null

End of function find

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.14 ms | 1399 KiB | 18 Q