3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?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]];
Output for 4.3.0 - 4.3.1, 4.3.3 - 4.4.0, 4.4.3 - 4.4.9, 5.0.1 - 5.1.4, 5.1.6 - 5.3.13, 5.3.18 - 5.3.23, 5.3.27, 5.4.0, 5.4.2 - 5.4.4, 5.4.6 - 5.4.8, 5.4.10 - 5.4.18, 5.4.20, 5.4.22 - 5.4.25, 5.4.27 - 5.4.29, 5.4.36 - 5.4.37, 5.4.39 - 5.5.26, 5.5.28 - 5.5.35, 5.6.9, 5.6.12 - 5.6.18, 5.6.20 - 5.6.28, 7.0.1 - 7.0.2, 7.0.4 - 7.1.0
00
Output for 4.4.1, 5.0.0, 5.3.25, 5.3.28, 5.4.1, 5.4.26, 5.4.31, 5.4.34, 5.4.38, 5.6.10, 5.6.19, 7.0.0, 7.0.3
01
Output for 4.3.2, 4.4.2, 5.1.5, 5.3.14 - 5.3.17, 5.3.24, 5.3.26, 5.3.29, 5.4.5, 5.4.9, 5.4.19, 5.4.21, 5.4.30, 5.4.32, 5.4.35, 5.5.27, 5.6.8, 5.6.11
02