超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<array_reversearray_shift>
Last updated: Fri, 22 Jun 2007

array_search

(PHP 4 >= 4.0.5, PHP 5)

array_search --  在数组中搜索给定的值,如果成功则返回相应的键名

说明

mixed array_search ( mixed needle, array haystack [, bool strict])

haystack 中搜索 needle 参数并在找到的情况下返回键名,否则返回 FALSE

注: 在 PHP 4.2.0 之前,array_search() 在失败时返回 NULL 而不是 FALSE

如果可选的第三个参数 strictTRUE,则 array_search() 还将在 haystack 中检查 needle 的类型。

警告

这个函数可能返回 Boolean FALSE,也可能返回一个与 FALSE 相等地非 Boolean 值,比如 0 或者 "" 。请参阅 Booleans 的有关章节以获取更多信息。请使用 === 操作符 来测试该函数的返回值。

参见 array_keys()array_values()array_key_exists()in_array()




add a note add a note User Contributed Notes
array_search
saconner at iastate dot edu
05-Feb-2002 05:16
In PHP versions before 4.2.0 needle was not allowed to be an array. (funnily enough, at time of posting this note, we're still at ver 4.1.1 )

<array_reversearray_shift>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22