There are two arrays that need to be changed within a function.
How to pass that arrays?
The way I know is to declare 2 arrays as global variables within a function:
function myfunc(){
global $arr1;
global $arr2;
//do something
}
Does it make sense and is it possible to pass two arrays as references instead? How (in case if Yes)?
Here is how you can pass them by reference, define your function as follows:
Just prepend the function arguments you want passed by reference with an
&. Now when they are received by the function, they are references.You do not have to (and should not) put the
&in front of the variables when you are calling the function as this results in a call-time pass-by-reference notice. Just pass them to your function as usual$res = myfunc($first, $second);See Passing by Reference