3v4l.org

run code in 500+ PHP versions simultaneously
<?php $reference = [ 'a' => 'this is A', 'b' => 'here is B', 'c' => 'C here', 'd' => 'finally, d', ]; $indexesToKeep = [1, 3]; $lookup = array_flip($indexesToKeep); $index = 0; $result = []; foreach ($reference as $key => $value) { if (isset($lookup[$index])) { $result[$key] = $value; } ++$index; } var_export($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 17
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 17
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 15
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 15
Branch analysis from position: 17
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 17
filename:       /in/Tvl0l
function name:  (null)
number of ops:  22
compiled vars:  !0 = $reference, !1 = $indexesToKeep, !2 = $lookup, !3 = $index, !4 = $result, !5 = $value, !6 = $key
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                       !0, <array>
   10     1        ASSIGN                                                       !1, <array>
   11     2        INIT_FCALL                                                   'array_flip'
          3        SEND_VAR                                                     !1
          4        DO_ICALL                                             $9      
          5        ASSIGN                                                       !2, $9
   12     6        ASSIGN                                                       !3, 0
   13     7        ASSIGN                                                       !4, <array>
   14     8      > FE_RESET_R                                           $13     !0, ->17
          9    > > FE_FETCH_R                                           ~14     $13, !5, ->17
         10    >   ASSIGN                                                       !6, ~14
   15    11        ISSET_ISEMPTY_DIM_OBJ                             0          !2, !3
         12      > JMPZ                                                         ~16, ->15
   16    13    >   ASSIGN_DIM                                                   !4, !6
         14        OP_DATA                                                      !5
   18    15    >   PRE_INC                                                      !3
   14    16      > JMP                                                          ->9
         17    >   FE_FREE                                                      $13
   20    18        INIT_FCALL                                                   'var_export'
         19        SEND_VAR                                                     !4
         20        DO_ICALL                                                     
         21      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
127.41 ms | 478 KiB | 9 Q