3v4l.org

run code in 300+ PHP versions simultaneously
<?php $data = ['First', 'Second', 'Third', 'Fourth', 'Fifth', 'Sixth']; $chose = []; $result = []; foreach($data as $i=>$item) { $pair = array_rand(array_diff_key($data, $chose, [$i])); $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 = 38
Branch analysis from position: 4
2 jumps found. (Code = 78) Position 1 = 5, Position 2 = 38
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 4
Branch analysis from position: 4
Branch analysis from position: 38
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 38
filename:       /in/jMibq
function name:  (null)
number of ops:  40
compiled vars:  !0 = $data, !1 = $chose, !2 = $result, !3 = $item, !4 = $i, !5 = $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                                       $9      !0, ->38
          4    > > FE_FETCH_R                                       ~10     $9, !3, ->38
          5    >   ASSIGN                                                   !4, ~10
    8     6        INIT_FCALL                                               'array_rand'
          7        INIT_FCALL                                               'array_diff_key'
          8        SEND_VAR                                                 !0
          9        SEND_VAR                                                 !1
         10        INIT_ARRAY                                       ~12     !4
         11        SEND_VAL                                                 ~12
         12        DO_ICALL                                         $13     
         13        SEND_VAR                                                 $13
         14        DO_ICALL                                         $14     
         15        ASSIGN                                                   !5, $14
    9    16        ASSIGN_DIM                                               !1
         17        OP_DATA                                                  !5
   10    18        INIT_ARRAY                                       ~18     !3
         19        FETCH_DIM_R                                      ~19     !0, !5
         20        ADD_ARRAY_ELEMENT                                ~18     ~19
         21        ASSIGN_DIM                                               !2
         22        OP_DATA                                                  ~18
   11    23        ECHO                                                     'Chosen%3A+%0A'
   12    24        INIT_FCALL                                               'var_dump'
         25        SEND_VAR                                                 !1
         26        DO_ICALL                                                 
   13    27        ECHO                                                     'Diff%3A+%0A'
   14    28        INIT_FCALL                                               'var_dump'
         29        INIT_FCALL                                               'array_diff_key'
         30        SEND_VAR                                                 !0
         31        SEND_VAR                                                 !1
         32        INIT_ARRAY                                       ~21     !4
         33        SEND_VAL                                                 ~21
         34        DO_ICALL                                         $22     
         35        SEND_VAR                                                 $22
         36        DO_ICALL                                                 
    6    37      > JMP                                                      ->4
         38    >   FE_FREE                                                  $9
   16    39      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
154.6 ms | 1396 KiB | 19 Q