$result = [ 'a'=>[1,2], 'b'=>[1,2], 'c'=>[1,2], 'd'=>[1,2],]array_intersect_ukey( $result['a'], $result['b'], $result['c'], $result['d'], 'test' );
Now the problem is, I don't know how many arrays there are in $result, there may be a-d, there may only be a and d.
The Array_intersect_ukey function is also dynamically based on this dynamic incoming parameter.
For example, only A and D
array_intersect_ukey( $result['a'], $result['d'], 'test' );
Like only A,c and D.
array_intersect_ukey( $result['a'], $result['c'], $result['d'], 'test' );
How do you implement this dynamic incoming parameter? Or is there any other way to implement it?
Reply content:
$result = [ 'a'=>[1,2], 'b'=>[1,2], 'c'=>[1,2], 'd'=>[1,2],]array_intersect_ukey( $result['a'], $result['b'], $result['c'], $result['d'], 'test' );
Now the problem is, I don't know how many arrays there are in $result, there may be a-d, there may only be a and d.
The Array_intersect_ukey function is also dynamically based on this dynamic incoming parameter.
For example, only A and D
array_intersect_ukey( $result['a'], $result['d'], 'test' );
Like only A,c and D.
array_intersect_ukey( $result['a'], $result['c'], $result['d'], 'test' );
How do you implement this dynamic incoming parameter? Or is there any other way to implement it?
I did not take a closer look at the landlord's question, but I told the landlord two points, I am sure is able to solve the problem described by the landlord:
1. Take note of a function called Call_user_func_array ()
http://php.net/manual/zh/function.call-user-func-array.php
2. This may not be as important as 1, but mention it:
Func_num_args (); Number of output parameters
Func_get_args; Get parameter, return parameter array
3. Since the number of parameters and the name is not determined, then, you can pass the 1 function to a function to pass parameters, remember the parameter array way, array can let you pass various parameters
Landlord of the problem, should be able to solve.
Back and carefully looked at the landlord's question, yes, Call_user_func_array can be to help you.
Can be called recursively or cyclically.
The A ∩ B ∩ C = ( A ∩ B ) ∩ C intersection of the first two arrays is computed, and then the intersection is computed with the result of the first calculation and the third array (if any), and so on.
I've asked a similar question before, https://segmentfault.com/q/1010000004290664.