3v4l.org

run code in 300+ PHP versions simultaneously
<?php $names = ['Adamelsini', 'Mark', 'Gonz', 'Tim']; $randomizer = function ($names) { if (1 === count($names) % 2) { $names[] = 'Pete'; } $pairs = []; $iteration = 0; while (count($names) > 0) { ++$iteration; if ($iteration > 10) break; $drawn = array_rand($names, 2); $pair = [$names[$drawn[0]], $names[$drawn[1]]]; unset($names[$drawn[0]], $names[$drawn[1]]); $pairs[] = $pair; } $result = "The PP randomizer has selected: \n"; foreach ($pairs as $p) { $result .= " -> {$p[0]} and {$p[1]}\n"; } return $result; }; echo $randomizer($names);
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/EOekU
function name:  (null)
number of ops:  8
compiled vars:  !0 = $names, !1 = $randomizer
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    3     0  E >   ASSIGN                                                   !0, <array>
    6     1        DECLARE_LAMBDA_FUNCTION                                  '%00%7Bclosure%7D%2Fin%2FEOekU%3A6%240'
          2        ASSIGN                                                   !1, ~3
   33     3        INIT_DYNAMIC_CALL                                        !1
          4        SEND_VAR_EX                                              !0
          5        DO_FCALL                                      0  $5      
          6        ECHO                                                     $5
          7      > RETURN                                                   1

Function %00%7Bclosure%7D%2Fin%2FEOekU%3A6%240:
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 43) Position 1 = 5, Position 2 = 7
Branch analysis from position: 5
1 jumps found. (Code = 42) Position 1 = 32
Branch analysis from position: 32
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 10
Branch analysis from position: 35
2 jumps found. (Code = 77) Position 1 = 37, Position 2 = 47
Branch analysis from position: 37
2 jumps found. (Code = 78) Position 1 = 38, Position 2 = 47
Branch analysis from position: 38
1 jumps found. (Code = 42) Position 1 = 37
Branch analysis from position: 37
Branch analysis from position: 47
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 47
Branch analysis from position: 10
2 jumps found. (Code = 43) Position 1 = 13, Position 2 = 14
Branch analysis from position: 13
1 jumps found. (Code = 42) Position 1 = 35
Branch analysis from position: 35
Branch analysis from position: 14
2 jumps found. (Code = 44) Position 1 = 35, Position 2 = 10
Branch analysis from position: 35
Branch analysis from position: 10
Branch analysis from position: 7
filename:       /in/EOekU
function name:  {closure}
number of ops:  50
compiled vars:  !0 = $names, !1 = $pairs, !2 = $iteration, !3 = $drawn, !4 = $pair, !5 = $result, !6 = $p
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    6     0  E >   RECV                                             !0      
    7     1        COUNT                                            ~7      !0
          2        MOD                                              ~8      ~7, 2
          3        IS_IDENTICAL                                             ~8, 1
          4      > JMPZ                                                     ~9, ->7
    8     5    >   ASSIGN_DIM                                               !0
          6        OP_DATA                                                  'Pete'
   11     7    >   ASSIGN                                                   !1, <array>
   13     8        ASSIGN                                                   !2, 0
   14     9      > JMP                                                      ->32
   15    10    >   PRE_INC                                                  !2
         11        IS_SMALLER                                               10, !2
         12      > JMPZ                                                     ~14, ->14
         13    > > JMP                                                      ->35
   17    14    >   INIT_FCALL                                               'array_rand'
         15        SEND_VAR                                                 !0
         16        SEND_VAL                                                 2
         17        DO_ICALL                                         $15     
         18        ASSIGN                                                   !3, $15
   19    19        FETCH_DIM_R                                      ~17     !3, 0
         20        FETCH_DIM_R                                      ~18     !0, ~17
         21        INIT_ARRAY                                       ~19     ~18
         22        FETCH_DIM_R                                      ~20     !3, 1
         23        FETCH_DIM_R                                      ~21     !0, ~20
         24        ADD_ARRAY_ELEMENT                                ~19     ~21
         25        ASSIGN                                                   !4, ~19
   20    26        FETCH_DIM_R                                      ~23     !3, 0
         27        UNSET_DIM                                                !0, ~23
         28        FETCH_DIM_R                                      ~24     !3, 1
         29        UNSET_DIM                                                !0, ~24
   22    30        ASSIGN_DIM                                               !1
         31        OP_DATA                                                  !4
   14    32    >   COUNT                                            ~26     !0
         33        IS_SMALLER                                               0, ~26
         34      > JMPNZ                                                    ~27, ->10
   25    35    >   ASSIGN                                                   !5, 'The+PP+randomizer+has+selected%3A+%0A'
   26    36      > FE_RESET_R                                       $29     !1, ->47
         37    > > FE_FETCH_R                                               $29, !6, ->47
   27    38    >   ROPE_INIT                                     5  ~33     '+-%3E+'
         39        FETCH_DIM_R                                      ~30     !6, 0
         40        ROPE_ADD                                      1  ~33     ~33, ~30
         41        ROPE_ADD                                      2  ~33     ~33, '+and+'
         42        FETCH_DIM_R                                      ~31     !6, 1
         43        ROPE_ADD                                      3  ~33     ~33, ~31
         44        ROPE_END                                      4  ~32     ~33, '%0A'
         45        ASSIGN_OP                                     8          !5, ~32
   26    46      > JMP                                                      ->37
         47    >   FE_FREE                                                  $29
   30    48      > RETURN                                                   !5
   31    49*     > RETURN                                                   null

End of function %00%7Bclosure%7D%2Fin%2FEOekU%3A6%240

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.29 ms | 1400 KiB | 15 Q