hihelllo 大佬有话说 :
php foreach数组取值判断的问题,php高手大佬看过来。
论坛提示代码非法无法发帖贴foreach代码,具体内容放在了腾讯文档,登陆应该可以编辑:https://docs.qq.com/doc/DV2F0REZzVFNKRUJz
数组:
Array
(
=> 1592620416
=> 查询成功
=> 0
=> Array
(
=> 3
=> Array
(
=> Array
(
=> 164
=> 996
=> 2020-06-18 09:00:33
=> 小卖铺
=> 张三
=> 100.00
=> 3
)
=> Array
(
=> 165
=> 996
=> 2020-06-18 09:00:33
=> 小卖铺
=> 李四
=> 200.00
=> 3
)
=> Array
(
=> 166
=> 996
=> 2020-06-18 09:00:33
=> 小卖铺
=> 李四
=> 200.00
=> 3
)
=> Array
(
=> 167
=> 996
=> 2020-06-18 09:00:33
=> 小卖铺
=> 王五
=> 150.00
=> 3
)
)
)
)
如何只取order_money为200里面的所有值呢?就是只取
=> Array
(
=> 166
=> 996
=> 2020-06-18 09:00:33
=> 小卖铺
=> 李四
=> 200.00
=> 3
)
里面的值。
inkedus 大佬有话说 :
帮顶https://cdn.jsdelivr.net/gh/hishis/forum-master/public/images/patch.gif
ezreal 大佬有话说 :
加个if不就完了.
首先你不知道这个$arr里面一共几个数组,肯定要先都查出来。然后for循环,加个if判断。
if($arr[‘data’][‘list’][$i][‘order_money’]==’200′)
菜鸟大婶 大佬有话说 :
$result = []
foreach($_[‘data’][‘list’] as $item){
if($item[‘order_money]’] == 200){
array_push($result,$item)
}
}
mean 大佬有话说 :
array_filter