Jump to content

Archived

This topic is now archived and is closed to further replies.

redbullmarky

[SOLVED] arrays/references - a quickie

Recommended Posts

Hi all
On PHP5 here - not sure if it makes a difference to the answer at all.

If a function/class method returns an array, is it best to pick it up by reference?

[code]
function myfunction()
{
   return $reallybigarray;
}

$thearray = myfunction();
[/code]

or

[code]
function myfunction()
{
   return $reallybigarray;
}

$thearray = &myfunction();
[/code]

cheers
Mark

Share this post


Link to post
Share on other sites
I think references are always the way to go when passing around arrays, whether it's PHP, Perl, etc. Otherwise, the array has to be copied.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.