3v4l.org

run code in 500+ 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 (count($pool) > 1) { $pullFrom = array_rand($pool); if (!$pool[$pullFrom]) { unset($pool[$pullFrom]); continue; } $result[] = array_shift($pool[$pullFrom]); } var_export(array_merge($result, ...$pool));
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 = 29, Position 2 = 11
Branch analysis from position: 29
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 = 29, Position 2 = 11
Branch analysis from position: 29
Branch analysis from position: 11
filename:       /in/sBgtv
function name:  (null)
number of ops:  38
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    >   COUNT                                                ~21     !4
         27        IS_SMALLER                                                   1, ~21
         28      > JMPNZ                                                        ~22, ->11
   18    29    >   INIT_FCALL                                                   'var_export'
         30        INIT_FCALL                                                   'array_merge'
         31        SEND_VAR                                                     !5
         32        SEND_UNPACK                                                  !4
         33        CHECK_UNDEF_ARGS                                             
         34        DO_ICALL                                             $23     
         35        SEND_VAR                                                     $23
         36        DO_ICALL                                                     
         37      > RETURN                                                       1

Generated using Vulcan Logic Dumper, using php 8.5.0


preferences:
156.5 ms | 1371 KiB | 16 Q