3v4l.org

run code in 500+ PHP versions simultaneously
<?php function getPairs($array) { $n = count($array); $keys = array_keys($array); $finalArray = []; $i = 0; foreach ($array as $a) { for ($x = $n-1; $i < $x; $x--) { $key1 = $keys[$i]; $key2 = $keys[$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/LfSZ4
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
-----------------------------------------------------------------------------------------
   18     0  E >   ASSIGN                                                       !0, 'arr1'
   19     1        ASSIGN                                                       !1, 'arr2'
   20     2        ASSIGN                                                       !2, 'arr3'
   23     3        INIT_ARRAY                                           ~8      !0, 'a'
   24     4        ADD_ARRAY_ELEMENT                                    ~8      !1, 'b'
   25     5        ADD_ARRAY_ELEMENT                                    ~8      !2, 'c'
   22     6        ASSIGN                                                       !3, ~8
   28     7        INIT_FCALL                                                   'getpairs'
          8        SEND_VAR                                                     !3
          9        DO_FCALL                                          0  $10     
         10        ASSIGN                                                       !4, $10
   29    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 = 10, Position 2 = 30
Branch analysis from position: 10
2 jumps found. (Code = 78) Position 1 = 11, Position 2 = 30
Branch analysis from position: 11
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 14
Branch analysis from position: 28
1 jumps found. (Code = 42) Position 1 = 10
Branch analysis from position: 10
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 28, Position 2 = 14
Branch analysis from position: 28
Branch analysis from position: 14
Branch analysis from position: 30
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 30
filename:       /in/LfSZ4
function name:  getPairs
number of ops:  33
compiled vars:  !0 = $array, !1 = $n, !2 = $keys, !3 = $finalArray, !4 = $i, !5 = $a, !6 = $x, !7 = $key1, !8 = $key2
line      #* E I O op                               fetch          ext  return  operands
-----------------------------------------------------------------------------------------
    2     0  E >   RECV                                                 !0      
    3     1        COUNT                                                ~9      !0
          2        ASSIGN                                                       !1, ~9
    4     3        INIT_FCALL                                                   'array_keys'
          4        SEND_VAR                                                     !0
          5        DO_ICALL                                             $11     
          6        ASSIGN                                                       !2, $11
    5     7        ASSIGN                                                       !3, <array>
    6     8        ASSIGN                                                       !4, 0
    7     9      > FE_RESET_R                                           $15     !0, ->30
         10    > > FE_FETCH_R                                                   $15, !5, ->30
    8    11    >   SUB                                                  ~16     !1, 1
         12        ASSIGN                                                       !6, ~16
         13      > JMP                                                          ->26
    9    14    >   FETCH_DIM_R                                          ~18     !2, !4
         15        ASSIGN                                                       !7, ~18
   10    16        FETCH_DIM_R                                          ~20     !2, !6
         17        ASSIGN                                                       !8, ~20
   11    18        CONCAT                                               ~22     !7, !8
         19        FETCH_DIM_R                                          ~24     !0, !7
         20        INIT_ARRAY                                           ~25     ~24
         21        FETCH_DIM_R                                          ~26     !0, !8
         22        ADD_ARRAY_ELEMENT                                    ~25     ~26
         23        ASSIGN_DIM                                                   !3, ~22
         24        OP_DATA                                                      ~25
    8    25        PRE_DEC                                                      !6
         26    >   IS_SMALLER                                                   !4, !6
         27      > JMPNZ                                                        ~28, ->14
   13    28    >   PRE_INC                                                      !4
    7    29      > JMP                                                          ->10
         30    >   FE_FREE                                                      $15
   15    31      > RETURN                                                       !3
   16    32*     > RETURN                                                       null

End of function getpairs

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
211.07 ms | 2668 KiB | 16 Q