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(array_diff_key($data, $chose, [$i])); } var_dump($result);
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 4, Position 2 = 29
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 29
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 29
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 29
filename:       /in/MLvVf
function name:  (null)
number of ops:  34
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, ->29
          4    > > FE_FETCH_R                                       ~11     $10, !3, ->29
          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
    6    28      > JMP                                                      ->4
         29    >   FE_FREE                                                  $10
   17    30        INIT_FCALL                                               'var_dump'
         31        SEND_VAR                                                 !2
         32        DO_ICALL                                                 
         33      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
179.54 ms | 1396 KiB | 21 Q