-2

I have a general php question. I have an array of size lets say size of 3. And I pass it as an input to a function in an included file. So, does it copy the array (more memory) or actually make the function to references it ?

$arr = array('a', 'b', 'c');
include(functions.php);    //doSomething() resides here
$result = doSomething($arr);
Elnoor
  • 3,401
  • 4
  • 24
  • 39

1 Answers1

1
$result = array('a', 'b', 'c');
include(functions.php);    //doSomething() resides here
doSomething($result);

and define

function doSomething(&$result) {/* code */}

And not use more memory..

Maxi Schvindt
  • 1,432
  • 1
  • 11
  • 20