php实现在多维数组中查找特定value的方法,多维value_PHP教程

WBOY
Release: 2016-07-13 09:45:53
Original
998 people have browsed it

php实现在多维数组中查找特定value的方法,多维value

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

最近做项目,需要从多维数组中查找是否含有特定的key和其对应特定的value,并清除该条数据,比如:

$arr = array(
//为了看的方便,数组表达形式不对
0=>array(id =>1,name =>"li")
1=>array(id =>2,name =>"na")
2=>array(id =>3,name =>"na")
)
)

Copy after login

希望达到效果:删除id为2的那一条记录:

public function searchArray($array,$key,$value){
foreach($array as $keyp=>$valuep){
if($valuep[$key]==$value){
unset($array[$keyp]);
}
}
return $array;
}

Copy after login

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

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/1039183.htmlTechArticlephp实现在多维数组中查找特定value的方法,多维value 本文实例讲述了php实现在多维数组中查找特定value的方法。分享给大家供大家参考。具体...
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!