3v4l.org

run code in 300+ PHP versions simultaneously
<?php $a = []; $a[0] = 2; $a[1] = 7; $a[2] = 5; $a[3] = 2; $a[4] = 2; $a[5] = 3; $min_val = min($a); $min_indexes = []; foreach($a as $i => $val){ if($val == $min_val) $min_indexes[] = $i; } print_r($min_indexes); echo $min_indexes[rand(0,count($min_indexes)-1)];
Finding entry points
Branch analysis from position: 0
2 jumps found. (Code = 77) Position 1 = 19, Position 2 = 26
Branch analysis from position: 19
2 jumps found. (Code = 78) Position 1 = 20, Position 2 = 26
Branch analysis from position: 20
2 jumps found. (Code = 43) Position 1 = 23, Position 2 = 25
Branch analysis from position: 23
1 jumps found. (Code = 42) Position 1 = 19
Branch analysis from position: 19
Branch analysis from position: 25
Branch analysis from position: 26
1 jumps found. (Code = 62) Position 1 = -2
Branch analysis from position: 26
filename:       /in/PXcq4
function name:  (null)
number of ops:  39
compiled vars:  !0 = $a, !1 = $min_val, !2 = $min_indexes, !3 = $val, !4 = $i
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    4     0  E >   ASSIGN                                                   !0, <array>
    5     1        ASSIGN_DIM                                               !0, 0
          2        OP_DATA                                                  2
    6     3        ASSIGN_DIM                                               !0, 1
          4        OP_DATA                                                  7
    7     5        ASSIGN_DIM                                               !0, 2
          6        OP_DATA                                                  5
    8     7        ASSIGN_DIM                                               !0, 3
          8        OP_DATA                                                  2
    9     9        ASSIGN_DIM                                               !0, 4
         10        OP_DATA                                                  2
   10    11        ASSIGN_DIM                                               !0, 5
         12        OP_DATA                                                  3
   13    13        INIT_FCALL                                               'min'
         14        SEND_VAR                                                 !0
         15        DO_ICALL                                         $12     
         16        ASSIGN                                                   !1, $12
   15    17        ASSIGN                                                   !2, <array>
   16    18      > FE_RESET_R                                       $15     !0, ->26
         19    > > FE_FETCH_R                                       ~16     $15, !3, ->26
         20    >   ASSIGN                                                   !4, ~16
   17    21        IS_EQUAL                                                 !3, !1
         22      > JMPZ                                                     ~18, ->25
         23    >   ASSIGN_DIM                                               !2
         24        OP_DATA                                                  !4
   16    25    > > JMP                                                      ->19
         26    >   FE_FREE                                                  $15
   20    27        INIT_FCALL                                               'print_r'
         28        SEND_VAR                                                 !2
         29        DO_ICALL                                                 
   21    30        INIT_FCALL                                               'rand'
         31        SEND_VAL                                                 0
         32        COUNT                                            ~21     !2
         33        SUB                                              ~22     ~21, 1
         34        SEND_VAL                                                 ~22
         35        DO_ICALL                                         $23     
         36        FETCH_DIM_R                                      ~24     !2, $23
         37        ECHO                                                     ~24
         38      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
142.29 ms | 1005 KiB | 16 Q