I have 2 arrays.
$result = array(); $row = array();
Line items are links and are constantly changing. For each iteration of $row I want to copy the values lines in the $result entry, not links.
I found several solutions, but they all seem pretty terrible.
$result[] = unserialize(serialize($row)); $result[] = array_flip(array_flip($row));
Both of these works, but seem like very unnecessary and ugly code to just copy the contents of an array of links by value, rather than copy the links themselves.
Is there a cleaner way to do this? If not for the most effective way?
Thanks.
EDIT: As shown below, for example:
function dereference($ref) { $dref = array(); foreach ($ref as $key => $value) { $dref[$key] = $value; } return $dref; } $result[] = dereference($row);
Also works, but seems just as ugly.
arrays reference php dereference
anomareh
source share