I have an array like below.
$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)
);
and applied filter like this.
$fa = array_filter($a, function ($item) {
return ($item["count"] > 0);
});
then i applied usort
on variable $fa
. After that i loop through $fa
and assigned some values, but they are not get reflected in variable $a
.
something like below,
usort($fa, 'comp');
foreach ($fa as &$t) {
$t["score"] = 120;
}
var_dump($a); //this doesn't contain "score" field.
So my questions is how to get filtered array with original array reference?