php - 如何在数组中搜索并取出想要的数据
给我你的怀抱
给我你的怀抱 2017-06-05 11:09:37
0
3
743

1.比如我有一堆数组如下:

Array
(
    [0] => Array
        (
            [gid] => 1
            [cid] => pc001
            [class] => 办公用品
            [name] => 笔记本电脑
            [type] => Acer Aspire E1-410G
            [unit] => 台
            [num] => 1
            [price] => 
            [amount] => 
            [invoice] => 
            [bremarks] => 
            [bid] => 
        )

    [1] => Array
        (
            [gid] => 2
            [cid] => pc002
            [class] => 办公用品
            [name] => 笔记本电脑
            [type] => Acer Aspire E5-571G-58WT
            [unit] => 台
            [num] => 2
            [price] => 
            [amount] => 
            [invoice] => 
            [bremarks] => 
            [bid] => 
        )

    [2] => Array
        (
            [gid] => 4
            [cid] => wf123
            [class] => 办公用品
            [name] => 鼠标
            [type] => 罗技M90
            [unit] => 个
            [num] => 3
            [price] => 
            [amount] => 
            [invoice] => 
            [bremarks] => 
            [bid] => 
        )

    [3] => Array
        (
            [gid] => 6
            [cid] => wf012
            [class] => 办公用品
            [name] => 电脑键盘
            [type] => PS接口
            [unit] => 个
            [num] => 4
            [price] => 
            [amount] => 
            [invoice] => 
            [bremarks] => 
            [bid] => 
        )

)

2.搜索条件如下:gid等于如下数组

Array
(
    [0] => 3
    [1] => 4
    [2] => 5
)

3.我如何把gid=3,4,5的数据取出来呢?
如上数据应该只有一条符合要求,求大神帮忙~

给我你的怀抱
给我你的怀抱

全部回复(3)
洪涛

foreach($arr_1 as $val){

雷雷

}
print_r($data);

PHPzhong

雷雷

漂亮男人

雷雷

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板