【发布时间】:2026-01-25 20:00:01
【问题描述】:
我创建一个这样的数组:
$table = Array();
array_push($table, Array('item' => 1, 'storage' = 1, 'qtd' = 0) );
array_push($table, Array('item' => 1, 'storage' = 2, 'qtd' = 4) );
array_push($table, Array('item' => 2, 'storage' = 1, 'qtd' = 78) );
array_push($table, Array('item' => 3, 'storage' = 2, 'qtd' = 10) );
我需要搜索我是否有一些物品在一些存储中.. 例如,在 sql 查询中,我喜欢“... where item = 1 and storage = 2”
如何在数组中以这种方式搜索,以获得“qtd”值?
谢谢!
【问题讨论】:
-
我想你在问如何搜索多维数组?
-
最简单的方法是使用带有回调函数的array_filter