How do I create (in PHP) and array of an array of objects? For example, say I have:
$arr[0] = array("eref_id" => "A001", "eref_child" => "A100", "level" => 1);
$arr[1] = array("eref_id" => "A002", "eref_child" => "A200", "level" => 2);
$arr[2] = array("eref_id" => "A003", "eref_child" => "A300", "level" => 3);
$arr[3] = array("eref_id" => "A003", "eref_child" => "A310", "level" => 3);
An I want a new array where the elements of "arr" are the "eref_id" and "eref_child" but the index to the array is the "level" element. So basically,
$newarr[1] would contain $arr[0]
$newarr[2] would contain $arr[1]
$newarr[3] would contain $arr[2]
and $arr[3]
(since both have a "level" of 3).
This would contain an array of $arr[2]
and $arr[3]
.
Hopefully this makes sense