3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array = array ( 'parent_id' => array ( 9 => array ( 0 => 11, 1 => 12 ), 10 => array ( 0 => 13, 1 => 14 ), 20 => array ( 0 => 21, 1 => 22 ), 21 => array ( 0 => 23 ) ) ); // re-index to 0 $array = array_values($array['parent_id']); // output array $pairs = array(); for ($i = 0; $i < count($array) - 1; $i += 2) { for ($j = 0; $j < min(count($array[$i]), count($array[$i+1])); $j++) { $pairs[] = array($array[$i][$j], $array[$i+1][$j]); } } print_r($pairs);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 33
Branch analysis from position: 33
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 9
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 9
1 jumps found. (Code = 42) Position 1 = 21
Branch analysis from position: 21
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 37, Position 2 = 9
Branch analysis from position: 37
Branch analysis from position: 9
Branch analysis from position: 11
2 jumps found. (Code = 44) Position 1 = 32, Position 2 = 11
Branch analysis from position: 32
Branch analysis from position: 11
filename:       /in/ps2pG
function name:  (null)
number of ops:  41
compiled vars:  !0 = $array, !1 = $pairs, !2 = $i, !3 = $j
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
   27     1        INIT_FCALL                                               'array_values'
          2        FETCH_DIM_R                                      ~5      !0, 'parent_id'
          3        SEND_VAL                                                 ~5
          4        DO_ICALL                                         $6      
          5        ASSIGN                                                   !0, $6
   29     6        ASSIGN                                                   !1, <array>
   30     7        ASSIGN                                                   !2, 0
          8      > JMP                                                      ->33
   31     9    >   ASSIGN                                                   !3, 0
         10      > JMP                                                      ->21
   32    11    >   FETCH_DIM_R                                      ~12     !0, !2
         12        FETCH_DIM_R                                      ~13     ~12, !3
         13        INIT_ARRAY                                       ~14     ~13
         14        ADD                                              ~15     !2, 1
         15        FETCH_DIM_R                                      ~16     !0, ~15
         16        FETCH_DIM_R                                      ~17     ~16, !3
         17        ADD_ARRAY_ELEMENT                                ~14     ~17
         18        ASSIGN_DIM                                               !1
         19        OP_DATA                                                  ~14
   31    20        PRE_INC                                                  !3
         21    >   INIT_FCALL                                               'min'
         22        FETCH_DIM_R                                      ~19     !0, !2
         23        COUNT                                            ~20     ~19
         24        SEND_VAL                                                 ~20
         25        ADD                                              ~21     !2, 1
         26        FETCH_DIM_R                                      ~22     !0, ~21
         27        COUNT                                            ~23     ~22
         28        SEND_VAL                                                 ~23
         29        DO_ICALL                                         $24     
         30        IS_SMALLER                                               !3, $24
         31      > JMPNZ                                                    ~25, ->11
   30    32    >   ASSIGN_OP                                     1          !2, 2
         33    >   COUNT                                            ~27     !0
         34        SUB                                              ~28     ~27, 1
         35        IS_SMALLER                                               !2, ~28
         36      > JMPNZ                                                    ~29, ->9
   35    37    >   INIT_FCALL                                               'print_r'
         38        SEND_VAR                                                 !1
         39        DO_ICALL                                                 
         40      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
137.71 ms | 1007 KiB | 16 Q