3v4l.org

run code in 300+ PHP versions simultaneously
<?php $assoc_arr = array("second" => array( array("position" => 4, "content" => "Valiant"), array("position" => 5, "content" => "Hail") ), "first" => array( array("position" => 0, "content" => "Hail"), array("position" => 3, "content" => "Victors"), array("position" => 2, "content" => "the"), array("position" => 1, "content" => "to") ) ); $order = array('first','second'); $arr = array(); foreach($order as $ord) { if(isset($assoc_arr[$ord])) { $arr = array_merge($arr, $assoc_arr[$ord]); } } $finalArray = array(); $proceed = true; $i = 0; foreach($arr as $a) { $finalArray[$a['position']] = $a['content']; } ksort($finalArray); print_r($finalArray);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 14
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 14
Branch analysis from position: 5
2 jumps found. (Code = 43) Position 1 = 7, Position 2 = 13
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 13
Branch analysis from position: 14
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 25
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 25
Branch analysis from position: 20
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 25
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 25
Branch analysis from position: 14
filename:       /in/EdLaD
function name:  (null)
number of ops:  33
compiled vars:  !0 = $assoc_arr, !1 = $order, !2 = $arr, !3 = $ord, !4 = $finalArray, !5 = $proceed, !6 = $i, !7 = $a
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
   22     1        ASSIGN                                                   !1, <array>
   23     2        ASSIGN                                                   !2, <array>
   25     3      > FE_RESET_R                                       $11     !1, ->14
          4    > > FE_FETCH_R                                               $11, !3, ->14
   26     5    >   ISSET_ISEMPTY_DIM_OBJ                         0          !0, !3
          6      > JMPZ                                                     ~12, ->13
   27     7    >   INIT_FCALL                                               'array_merge'
          8        SEND_VAR                                                 !2
          9        FETCH_DIM_R                                      ~13     !0, !3
         10        SEND_VAL                                                 ~13
         11        DO_ICALL                                         $14     
         12        ASSIGN                                                   !2, $14
   25    13    > > JMP                                                      ->4
         14    >   FE_FREE                                                  $11
   31    15        ASSIGN                                                   !4, <array>
   32    16        ASSIGN                                                   !5, <true>
   33    17        ASSIGN                                                   !6, 0
   35    18      > FE_RESET_R                                       $19     !2, ->25
         19    > > FE_FETCH_R                                               $19, !7, ->25
   36    20    >   FETCH_DIM_R                                      ~20     !7, 'position'
         21        FETCH_DIM_R                                      ~22     !7, 'content'
         22        ASSIGN_DIM                                               !4, ~20
         23        OP_DATA                                                  ~22
   35    24      > JMP                                                      ->19
         25    >   FE_FREE                                                  $19
   39    26        INIT_FCALL                                               'ksort'
         27        SEND_REF                                                 !4
         28        DO_ICALL                                                 
   41    29        INIT_FCALL                                               'print_r'
         30        SEND_VAR                                                 !4
         31        DO_ICALL                                                 
         32      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
161.93 ms | 1388 KiB | 19 Q