3v4l.org

run code in 300+ PHP versions simultaneously
<?php $headers = array( 'one', 'two', 'three', ); $data = array( 'three' => 'someva3', 'one' => 'someval1', 'two' => 'someval2' ); $expected = array( 'someval1', 'someval2', 'someval3' ); $positions = array_flip($headers); $output = array(); foreach($data as $key => $item) { $position = $positions[$key]; $output[$position] = $item; } ksort($output); var_dump($output);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 9, Position 2 = 16
Branch analysis from position: 9
2 jumps found. (Code = 78) Position 1 = 10, Position 2 = 16
Branch analysis from position: 10
1 jumps found. (Code = 42) Position 1 = 9
Branch analysis from position: 9
Branch analysis from position: 16
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 16
filename:       /in/WEseA
function name:  (null)
number of ops:  24
compiled vars:  !0 = $headers, !1 = $data, !2 = $expected, !3 = $positions, !4 = $output, !5 = $item, !6 = $key, !7 = $position
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    9     1        ASSIGN                                                   !1, <array>
   15     2        ASSIGN                                                   !2, <array>
   21     3        INIT_FCALL                                               'array_flip'
          4        SEND_VAR                                                 !0
          5        DO_ICALL                                         $11     
          6        ASSIGN                                                   !3, $11
   23     7        ASSIGN                                                   !4, <array>
   24     8      > FE_RESET_R                                       $14     !1, ->16
          9    > > FE_FETCH_R                                       ~15     $14, !5, ->16
         10    >   ASSIGN                                                   !6, ~15
   25    11        FETCH_DIM_R                                      ~17     !3, !6
         12        ASSIGN                                                   !7, ~17
   26    13        ASSIGN_DIM                                               !4, !7
         14        OP_DATA                                                  !5
   24    15      > JMP                                                      ->9
         16    >   FE_FREE                                                  $14
   28    17        INIT_FCALL                                               'ksort'
         18        SEND_REF                                                 !4
         19        DO_ICALL                                                 
   29    20        INIT_FCALL                                               'var_dump'
         21        SEND_VAR                                                 !4
         22        DO_ICALL                                                 
         23      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
158.65 ms | 1395 KiB | 19 Q