我有一个像下面这样的数组。
$a = array(
array("id" => 1, "name" => "njx", "count" => 0),
array("id" => 2, "name" => "peter", "count" => 4),
array("id" => 3, "name" => "jeffry", "count" => 2),
array("id" => 4, "name" => "adam", "count" => 6)
);
并像这样应用过滤器。
$fa = array_filter($a, function ($item) {
return ($item["count"] > 0);
});
然后我申请usort
了变量$fa
。之后我循环$fa
并分配了一些值,但它们没有反映在变量中$a
。
像下面的东西,
usort($fa, 'comp');
foreach ($fa as &$t) {
$t["score"] = 120;
}
var_dump($a); //this doesn't contain "score" field.
所以我的问题是如何使用原始数组引用获得过滤数组?