Home  >  Article  >  php教程  >  php在数组中查找指定值的方法

php在数组中查找指定值的方法

WBOY
WBOYOriginal
2016-06-06 20:06:291007browse

这篇文章主要介绍了php在数组中查找指定值的方法,实例分析了php中array_search函数查找数组指定值的使用技巧,具有一定参考借鉴价值,需要的朋友可以参考下

本文实例讲述了php在数组中查找指定值的方法。分享给大家供大家参考。具体如下:

php中有两个函数可以判断数组中是否包含指定的值,,分别是:array_search($value, $array)和in_array($value, $array),array_search可以找出指定的值在数组中出现的位置,in_array函数只判断数组中是否存在指定的值,返回bool值

输出结果如下

Search 1: 1 Search 2: 0 Search 3:

希望本文所述对大家的php程序设计有所帮助。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn