我是 php 数组的新手。我找不到解决方案。
这是我的代码:
$animals = Array
(
1=>$duck,
2=>$horse,
3=>$rabbit
);
ForEach($animals As $animal)
{
echo $animals[Array_Rand($animals)];
}
现在我想从数组中选择一个合适的变量,即 $rabbit。
就像是:
if($animal[3]){
echo 'The rabbit just spawned';
}
请告诉我如何使用 if 指令引用变量号 3(兔子)。