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]"; $result->os->funct = function (){ return 'qsdf'; }; $ret = array(); foreach ( $data as $object => $values ) { $ret[$object] = array_intersect_key( (array) $result->$object, array_flip( $values ) ); } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 45, Position 2 = 59
Branch analysis from position: 45
2 jumps found. (Code = 78) Position 1 = 46, Position 2 = 59
Branch analysis from position: 46
1 jumps found. (Code = 42) Position 1 = 45
Branch analysis from position: 45
Branch analysis from position: 59
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 59
filename:       /in/hYfjh
function name:  (null)
number of ops:  64
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'
   19    39        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FhYfjh%3A19%240'
         40        FETCH_OBJ_W                                      $33     !1, 'os'
         41        ASSIGN_OBJ                                               $33, 'funct'
         42        OP_DATA                                                  ~35
   22    43        ASSIGN                                                   !2, <array>
   23    44      > FE_RESET_R                                       $37     !0, ->59
         45    > > FE_FETCH_R                                       ~38     $37, !3, ->59
         46    >   ASSIGN                                                   !4, ~38
   25    47        INIT_FCALL                                               'array_intersect_key'
         48        FETCH_OBJ_R                                      ~41     !1, !4
         49        CAST                                          7  ~42     ~41
         50        SEND_VAL                                                 ~42
         51        INIT_FCALL                                               'array_flip'
         52        SEND_VAR                                                 !3
         53        DO_ICALL                                         $43     
         54        SEND_VAR                                                 $43
         55        DO_ICALL                                         $44     
         56        ASSIGN_DIM                                               !2, !4
         57        OP_DATA                                                  $44
   23    58      > JMP                                                      ->45
         59    >   FE_FREE                                                  $37
   28    60        INIT_FCALL                                               'var_dump'
         61        SEND_VAR                                                 !1
         62        DO_ICALL                                                 
         63      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FhYfjh%3A19%240:
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/hYfjh
function name:  {closure}
number of ops:  2
compiled vars:  none
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E > > RETURN                                                   'qsdf'
          1*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FhYfjh%3A19%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
156.6 ms | 1400 KiB | 19 Q