3v4l.org

run code in 300+ PHP versions simultaneously
<?php function getPairs($array) { $n = count($array); $finalArray = []; $i = 0; foreach ($array as $a) { for ($x = $n-1; $i < $x; $x--) { $key1 = array_keys($array)[$i]; $key2 = array_keys($array)[$x]; $finalArray[$key1.$key2] = [$array[$key1], $array[$key2]]; } $i++; } return $finalArray; } $arr1 = 'arr1'; $arr2 = 'arr2'; $arr3 = 'arr3'; $merged = [ 'a'=> $arr1, 'b'=> $arr2, 'c'=> $arr3 ]; $pairs = getPairs($merged); print_r($pairs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/DAMSb
function name:  (null)
number of ops:  15
compiled vars:  !0 = $arr1, !1 = $arr2, !2 = $arr3, !3 = $merged, !4 = $pairs
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
   19     0  E >   ASSIGN                                                   !0, 'arr1'
   20     1        ASSIGN                                                   !1, 'arr2'
   21     2        ASSIGN                                                   !2, 'arr3'
   24     3        INIT_ARRAY                                       ~8      !0, 'a'
   25     4        ADD_ARRAY_ELEMENT                                ~8      !1, 'b'
   26     5        ADD_ARRAY_ELEMENT                                ~8      !2, 'c'
   23     6        ASSIGN                                                   !3, ~8
   29     7        INIT_FCALL                                               'getpairs'
          8        SEND_VAR                                                 !3
          9        DO_FCALL                                      0  $10     
         10        ASSIGN                                                   !4, $10
   30    11        INIT_FCALL                                               'print_r'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                                 
         14      > RETURN                                                   1

Function getpairs:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 6, Position 2 = 32
Branch analysis from position: 6
2 jumps found. (Code = 78) Position 1 = 7, Position 2 = 32
Branch analysis from position: 7
1 jumps found. (Code = 42) Position 1 = 28
Branch analysis from position: 28
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 10
Branch analysis from position: 30
1 jumps found. (Code = 42) Position 1 = 6
Branch analysis from position: 6
Branch analysis from position: 10
2 jumps found. (Code = 44) Position 1 = 30, Position 2 = 10
Branch analysis from position: 30
Branch analysis from position: 10
Branch analysis from position: 32
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 32
filename:       /in/DAMSb
function name:  getPairs
number of ops:  35
compiled vars:  !0 = $array, !1 = $n, !2 = $finalArray, !3 = $i, !4 = $a, !5 = $x, !6 = $key1, !7 = $key2
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   RECV                                             !0      
    3     1        COUNT                                            ~8      !0
          2        ASSIGN                                                   !1, ~8
    5     3        ASSIGN                                                   !2, <array>
    6     4        ASSIGN                                                   !3, 0
    7     5      > FE_RESET_R                                       $12     !0, ->32
          6    > > FE_FETCH_R                                               $12, !4, ->32
    8     7    >   SUB                                              ~13     !1, 1
          8        ASSIGN                                                   !5, ~13
          9      > JMP                                                      ->28
    9    10    >   INIT_FCALL                                               'array_keys'
         11        SEND_VAR                                                 !0
         12        DO_ICALL                                         $15     
         13        FETCH_DIM_R                                      ~16     $15, !3
         14        ASSIGN                                                   !6, ~16
   10    15        INIT_FCALL                                               'array_keys'
         16        SEND_VAR                                                 !0
         17        DO_ICALL                                         $18     
         18        FETCH_DIM_R                                      ~19     $18, !5
         19        ASSIGN                                                   !7, ~19
   11    20        CONCAT                                           ~21     !6, !7
         21        FETCH_DIM_R                                      ~23     !0, !6
         22        INIT_ARRAY                                       ~24     ~23
         23        FETCH_DIM_R                                      ~25     !0, !7
         24        ADD_ARRAY_ELEMENT                                ~24     ~25
         25        ASSIGN_DIM                                               !2, ~21
         26        OP_DATA                                                  ~24
    8    27        PRE_DEC                                                  !5
         28    >   IS_SMALLER                                               !3, !5
         29      > JMPNZ                                                    ~27, ->10
   13    30    >   PRE_INC                                                  !3
    7    31      > JMP                                                      ->6
         32    >   FE_FREE                                                  $12
   16    33      > RETURN                                                   !2
   17    34*     > RETURN                                                   null

End of function getpairs

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
147 ms | 1403 KiB | 18 Q