3v4l.org

run code in 300+ PHP versions simultaneously
<?php $main_array=array('00','01','02'); $priority=array(0,0,0,0,0,0,0,0,1,2); $rand_index=array_rand($priority);//select a random index from priority array.. $priority[$rand_index] will give you index 0 or 1 or 2 with your priority set.. echo $main_array[$priority[$rand_index]];
Finding entry points
Branch analysis from position: 0
1 jumps found. (Code = 62) Position 1 = -2
filename:       /in/GucKH
function name:  (null)
number of ops:  10
compiled vars:  !0 = $main_array, !1 = $priority, !2 = $rand_index
line      #* E I O op                           fetch          ext  return  operands
-------------------------------------------------------------------------------------
    2     0  E >   ASSIGN                                                   !0, <array>
    4     1        ASSIGN                                                   !1, <array>
    6     2        INIT_FCALL                                               'array_rand'
          3        SEND_VAR                                                 !1
          4        DO_ICALL                                         $5      
          5        ASSIGN                                                   !2, $5
    8     6        FETCH_DIM_R                                      ~7      !1, !2
          7        FETCH_DIM_R                                      ~8      !0, ~7
          8        ECHO                                                     ~8
          9      > RETURN                                                   1

Generated using Vulcan Logic Dumper, using php 8.0.0


preferences:
157.74 ms | 1385 KiB | 15 Q