Cytat
sneskid at hotmail dot com 03-Aug-2009 07:22
As already mentioned, array_pop always returns a copy, never a reference, which can be a problem in some cases.
Here is a pop function that allows you to get the reference.
(keep in mind it will alter the internal pointer of the array)
As already mentioned, array_pop always returns a copy, never a reference, which can be a problem in some cases.
Here is a pop function that allows you to get the reference.
(keep in mind it will alter the internal pointer of the array)
function &array_rpop(&$a){ $v=&$a[$k]; return $v; } // try this: $A='A'; //$C=&array_rpop($B); // will work $C=&array_pop($B); // won't work $C='C';
Cytat
I hope the PHP people will make the regular function work with references.
Pomyślałem żeby zrobić u siebie implementację takiej funkcji ale nie wiem, czy jest to najbardziej wydajne rozwiązanie? Czy może bardziej opłaca się zrobić coś w stylu poniższego kodu?
$copiedArr = $originalArr;