3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth']; $chose = []; $result = []; foreach($data as $i=>$item) { $keys = array_diff(array_keys($data), $chose, [$i]); $pair = $keys[array_rand($keys)]; $chose[] = $pair; $result[]= [$item, $data[$pair]]; echo("Chosen: \n"); var_dump($chose); echo("Diff: \n"); var_dump($keys); } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 37
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 37
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 37
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 37
filename:       /in/9K8Pl
function name:  (null)
number of ops:  42
compiled vars:  !0 = $data, !1 = $chose, !2 = $result, !3 = $item, !4 = $i, !5 = $keys, !6 = $pair
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    5     2        ASSIGN                                                   !2, <array>
    6     3      > FE_RESET_R                                       $10     !0, ->37
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->37
          5    >   ASSIGN                                                   !4, ~11
    8     6        INIT_FCALL                                               'array_diff'
          7        INIT_FCALL                                               'array_keys'
          8        SEND_VAR                                                 !0
          9        DO_ICALL                                         $13     
         10        SEND_VAR                                                 $13
         11        SEND_VAR                                                 !1
         12        INIT_ARRAY                                       ~14     !4
         13        SEND_VAL                                                 ~14
         14        DO_ICALL                                         $15     
         15        ASSIGN                                                   !5, $15
    9    16        INIT_FCALL                                               'array_rand'
         17        SEND_VAR                                                 !5
         18        DO_ICALL                                         $17     
         19        FETCH_DIM_R                                      ~18     !5, $17
         20        ASSIGN                                                   !6, ~18
   10    21        ASSIGN_DIM                                               !1
         22        OP_DATA                                                  !6
   11    23        INIT_ARRAY                                       ~22     !3
         24        FETCH_DIM_R                                      ~23     !0, !6
         25        ADD_ARRAY_ELEMENT                                ~22     ~23
         26        ASSIGN_DIM                                               !2
         27        OP_DATA                                                  ~22
   12    28        ECHO                                                     'Chosen%3A+%0A'
   13    29        INIT_FCALL                                               'var_dump'
         30        SEND_VAR                                                 !1
         31        DO_ICALL                                                 
   14    32        ECHO                                                     'Diff%3A+%0A'
   15    33        INIT_FCALL                                               'var_dump'
         34        SEND_VAR                                                 !5
         35        DO_ICALL                                                 
    6    36      > JMP                                                      ->4
         37    >   FE_FREE                                                  $10
   17    38        INIT_FCALL                                               'var_dump'
         39        SEND_VAR                                                 !2
         40        DO_ICALL                                                 
         41      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
159.03 ms | 1400 KiB | 21 Q