array_rand() 从数组中随机取出一个或多个单元
【功能】
该函数将返回一个数组中的指定个数的数组元素。
如果只取出一个该函数将返回一个随机单元的键名,否则就返回一个包含随机键名的数组
这样就可以随机从数组中随机取出键名和值
【使用范围】
php4、php5.
【使用】
mixed array_rand( array input[.int num_req] )
返回值为混合型,参数input为即将进行取出操作的原始数组
可选参数num_req为即将取出的元素个数
【示例】
[php]
srand((float)microtime()*10000000);
$input=array("Neo","Morpheus","Trinity","Cypher","Than");
var_dump(array_rand($input,2));
/*
array(2) {
[0]=>
int(0)
[1]=>
int(4)
}
*/
摘自 zuodefeng的笔记

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

SublimeText3 Linux new version
SublimeText3 Linux latest version

Dreamweaver CS6
Visual web development tools