3v4l.org

run code in 300+ PHP versions simultaneously
<?php $first = [1, 2, 3, 4]; $second = [10, 20, 30, 40]; $third = []; $fourth = ['a', 'b']; $pool = [$first, $second, $third, $fourth]; $result = []; while ($pool) { $pullFrom = array_rand($pool); if (!$pool[$pullFrom]) { unset($pool[$pullFrom]); continue; } $result[] = array_shift($pool[$pullFrom]); } var_export($result);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 11
Branch analysis from position: 27
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 11
2 jumps found. (Code = 43) Position 1 = 18, Position 2 = 20
Branch analysis from position: 18
1 jumps found. (Code = 42) Position 1 = 26
Branch analysis from position: 26
Branch analysis from position: 20
2 jumps found. (Code = 44) Position 1 = 27, Position 2 = 11
Branch analysis from position: 27
Branch analysis from position: 11
filename:       /in/coS84
function name:  (null)
number of ops:  31
compiled vars:  !0 = $first, !1 = $second, !2 = $third, !3 = $fourth, !4 = $pool, !5 = $result, !6 = $pullFrom
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        ASSIGN                                                   !3, <array>
    8     4        INIT_ARRAY                                       ~11     !0
          5        ADD_ARRAY_ELEMENT                                ~11     !1
          6        ADD_ARRAY_ELEMENT                                ~11     !2
          7        ADD_ARRAY_ELEMENT                                ~11     !3
          8        ASSIGN                                                   !4, ~11
    9     9        ASSIGN                                                   !5, <array>
   10    10      > JMP                                                      ->26
   11    11    >   INIT_FCALL                                               'array_rand'
         12        SEND_VAR                                                 !4
         13        DO_ICALL                                         $14     
         14        ASSIGN                                                   !6, $14
   12    15        FETCH_DIM_R                                      ~16     !4, !6
         16        BOOL_NOT                                         ~17     ~16
         17      > JMPZ                                                     ~17, ->20
   13    18    >   UNSET_DIM                                                !4, !6
   14    19      > JMP                                                      ->26
   16    20    >   INIT_FCALL                                               'array_shift'
         21        FETCH_DIM_W                                      $19     !4, !6
         22        SEND_REF                                                 $19
         23        DO_ICALL                                         $20     
         24        ASSIGN_DIM                                               !5
         25        OP_DATA                                                  $20
   10    26    > > JMPNZ                                                    !4, ->11
   18    27    >   INIT_FCALL                                               'var_export'
         28        SEND_VAR                                                 !5
         29        DO_ICALL                                                 
         30      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
135.6 ms | 1003 KiB | 16 Q