我有这个用户代理的数组
$userAgents = array ('Mozilla/5.0 (Windows NT 6.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1', //FF4
'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:15.0) Gecko/20120427 Firefox/15.0a1', //F15
'Opera/9.80 (Macintosh; Intel Mac OS X; U; en) Presto/2.2.15 Version/10.00', //O10
'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.3 Safari/534.53.10', //S5
'Mozilla/4.0 (compatible; MSIE 7.0b; Windows NT 5.1)', //IE7
'Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.0; WOW64; Trident/4.0; SLCC1)' //IE8
'Mozilla/5.0 (MSIE 9.0; Windows NT 6.1; Trident/5.0)' //IE9
);
我想随机获得一个不同的用户代理,所以我使用了:
$userAgent = $userAgents[array_rand($userAgents)];
我怎样才能做同样的随机选择,但给予更多的权重,比如说,3个第一个数组条目......?