您的位置:首页 > 编程语言 > PHP开发

PHP 数据库查询结果转换数组后进行再查询过滤

2016-06-13 20:45 736 查看
//filterArrays($category_result,array(array("col"=>"id","val"=>"49"),array("col"=>"borrow_nid","val"=>"20160500064")));

function filterArrays($list = array(),$where = array()){

$index = 0;

foreach ($list as $key => $value){

$mached = 0;

foreach($where as $wk=>$wv){

//self::log($wv['col']);

//self::log($wv['val']);

if($value[$wv['col']] == $wv['val']){

$mached++;

}

}

if($mached==count($where)){

$data['row'] = $value;

$data['index'] = $index;

return $data;

}

/*

foreach ($value as $_key => $_value){

if($_key==$where['col'] && $_value==$where['val']){

$data['row'] = $value;

$data['index'] = $index;

return $data;

}

}

*/

$index++;

}

$data['row'] = null;

$data['index'] = -1;

return $data;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: