3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = array( 'ua' => array( 'family', 'major' ), 'os' => array( 'family', 'major' ) ); $result = new StdClass(); $result->ua = new StdClass(); $result->ua->family = "Safari"; $result->ua->major = "6"; $result->ua->minor = "0"; $result->ua->patch = "2"; $result->os = new StdClass(); $result->os->family = "Mac OS X"; $result->os->major = "10"; $result->os->minor = "7"; $result->os->patch = "5"; $result->os->patchMinor = "[null]"; $ret = array(); foreach ( $data as $object => $values ) { $ret += array_intersect_key( (array) $result->$object, array_flip($values) ); } var_dump($ret);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 41, Position 2 = 54
Branch analysis from position: 41
2 jumps found. (Code = 78) Position 1 = 42, Position 2 = 54
Branch analysis from position: 42
1 jumps found. (Code = 42) Position 1 = 41
Branch analysis from position: 41
Branch analysis from position: 54
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 54
filename:       /in/ptgV8
function name:  (null)
number of ops:  59
compiled vars:  !0 = $data, !1 = $result, !2 = $ret, !3 = $values, !4 = $object
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    5     1        NEW                                              $6      'StdClass'
          2        DO_FCALL                                      0          
          3        ASSIGN                                                   !1, $6
    7     4        NEW                                              $10     'StdClass'
          5        DO_FCALL                                      0          
          6        ASSIGN_OBJ                                               !1, 'ua'
          7        OP_DATA                                                  $10
    8     8        FETCH_OBJ_W                                      $12     !1, 'ua'
          9        ASSIGN_OBJ                                               $12, 'family'
         10        OP_DATA                                                  'Safari'
    9    11        FETCH_OBJ_W                                      $14     !1, 'ua'
         12        ASSIGN_OBJ                                               $14, 'major'
         13        OP_DATA                                                  '6'
   10    14        FETCH_OBJ_W                                      $16     !1, 'ua'
         15        ASSIGN_OBJ                                               $16, 'minor'
         16        OP_DATA                                                  '0'
   11    17        FETCH_OBJ_W                                      $18     !1, 'ua'
         18        ASSIGN_OBJ                                               $18, 'patch'
         19        OP_DATA                                                  '2'
   13    20        NEW                                              $21     'StdClass'
         21        DO_FCALL                                      0          
         22        ASSIGN_OBJ                                               !1, 'os'
         23        OP_DATA                                                  $21
   14    24        FETCH_OBJ_W                                      $23     !1, 'os'
         25        ASSIGN_OBJ                                               $23, 'family'
         26        OP_DATA                                                  'Mac+OS+X'
   15    27        FETCH_OBJ_W                                      $25     !1, 'os'
         28        ASSIGN_OBJ                                               $25, 'major'
         29        OP_DATA                                                  '10'
   16    30        FETCH_OBJ_W                                      $27     !1, 'os'
         31        ASSIGN_OBJ                                               $27, 'minor'
         32        OP_DATA                                                  '7'
   17    33        FETCH_OBJ_W                                      $29     !1, 'os'
         34        ASSIGN_OBJ                                               $29, 'patch'
         35        OP_DATA                                                  '5'
   18    36        FETCH_OBJ_W                                      $31     !1, 'os'
         37        ASSIGN_OBJ                                               $31, 'patchMinor'
         38        OP_DATA                                                  '%5Bnull%5D'
   21    39        ASSIGN                                                   !2, <array>
   22    40      > FE_RESET_R                                       $34     !0, ->54
         41    > > FE_FETCH_R                                       ~35     $34, !3, ->54
         42    >   ASSIGN                                                   !4, ~35
   24    43        INIT_FCALL                                               'array_intersect_key'
         44        FETCH_OBJ_R                                      ~37     !1, !4
         45        CAST                                          7  ~38     ~37
         46        SEND_VAL                                                 ~38
         47        INIT_FCALL                                               'array_flip'
         48        SEND_VAR                                                 !3
         49        DO_ICALL                                         $39     
         50        SEND_VAR                                                 $39
         51        DO_ICALL                                         $40     
         52        ASSIGN_OP                                     1          !2, $40
   22    53      > JMP                                                      ->41
         54    >   FE_FREE                                                  $34
   27    55        INIT_FCALL                                               'var_dump'
         56        SEND_VAR                                                 !2
         57        DO_ICALL                                                 
         58      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.85 ms | 1400 KiB | 19 Q