Just like following:
// situation1: pass whole array, and function use a part of this array.
function funcA1($array) {
return $array['a']['a1'];
}
// situation2: pass $array['a'];
function funcA2($array) {
return $array['a1'];
}
$a = ['a' => ['a1' => 1, 'a2' => 2], 'b' => 2, 'c' => 3];
$situation1 = funcA1($a);
$situation2 = funcA2($a['a']);
I think situation1 use more memory, but it's simple to use, and situation2 use less memory, but difficult to use. Is it right?
In the case of the array is very large and the funciton will be called for a lot of times, what solution should I choose, or other solution? And Why?