PHP值存在于数组中

时间:2013-07-06 08:28:28

标签: php arrays exists

好的,情况如下:

$x = array('yo'=>12,'go'=>13);

如何测试值是否在数组中?

例如:

isThereInArray(12) => True or 1 or whatever
isThereInArray(123) => False or 0 or null or -1 or whatever

1 个答案:

答案 0 :(得分:3)

in_array()会帮助你。

要获得更快速的开发,请查阅PHP文档,如下所示:

http://au1.php.net/manual-lookup.php?pattern=find+in+array&lang=en&scope=quickref

相关问题