Home  >  Article  >  Backend Development  >  检测某列中是不是存在某值,更好的办法吗

检测某列中是不是存在某值,更好的办法吗

WBOY
WBOYOriginal
2016-06-13 10:37:48917browse

检测某列中是否存在某值,更好的办法吗?

PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->array(0=> array(a=>0,b=>5,c=>5,d=>23),1=> array(a=>45,b=>5,c=>5,d=>23),2=> array(a=>21,b=>5,c=>5,d=>23),3=> array(a=>11,b=>5,c=>5,d=>23),);



检测是否其中某列的a 是否等于45并返回下标 这个只能遍历数组吗?

------解决方案--------------------
唔...这样吧

foreach($arr as $tmparr){
echo array_search(45, $tmparr);
}
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