Reputation: 11
I don't know is there such thing as dynamic array_intersect? Anyway i have 3 arrays ( later there will be much more arrays)
$kaID = array();
$tgID = array();
$ciID = array();
I want to find matching values for all arrays using array_intersect Arrays can be created and filled with values or not. It can be only one populated array OR there can be all three. (later on there will be much more arrays.
How to iterate and create some kind of dynamic expression and get something like this:
array_intersect ($kaID, $tgID,$ciID,.... );
Upvotes: 1
Views: 980
Reputation: 825
You can do something like this:
$collection = [];
//Dynamic
foreach($ids as $id) {
$collection[] = $id;
}
$result = call_user_func_array('array_intersect', $collection);
Upvotes: 6