Forum Moderators: coopster
<?php
$testArray=array(1,259,639,3,26,216,9576,1346);
$testArray=normalCall($testArray);
print_r($testArray);
function normalCall($anyArray)
{
sort($anyArray); // just for example
return $anyArray;
}
?>
<?php
$testArray=array(1,259,639,3,26,216,9576,1346);
referenceCall($testArray); // notice you dont have to assign it back
print_r($testArray);
function referenceCall(&$anyArray)
{
sort($anyArray); // just for example
return $anyArray;
}
?>
And also a pointer wont take alot of memory, cause it does not hold the "value" of that variable. It only holds the memory address where that variable is located / starts from (in case of an array or lists). So it only contains value of a memory address.
So I guess as =& is a bitwise operator?
&= is a 'Bitwise And' assignment operator: $a &= $b ...same as... $a = $a & $b function &newName()
...means that $b is a pointer/reference to/of $a
...I like this idea of passing things by reference, especially as it doesn't take up much memory