From: robert mena on
Hi,

I have a result set coming from a database that can be of the form below

$lines = array(0 => array('idA' => 1, 'idU' => 1),
1 => array('idA' => 1, 'idU' => 2),
2 => array('idA' => 2, 'idU' => 1),
3 => array('idA' => 2, 'idU' => 2),
4 => array('idA' => 3, 'idU' => 1),
5 => array('idA' => 3, 'idU' => 2));

I used the code to generate arrays based on the idA, i.e, one array
containing all the idU from each idA

foreach ($lines as $r)
{
if(!isset($list[$r['idA']]))
{
$list[$r['idA']] = array();
}

array_push($list[$r['idA']], $r['idU']);
}

Now need just the idU that occurs in all.

In my example I could simply

$x = array_intersect($list[1], $list[2], $list[3]);

This works but the problem is that I do not know in advance how many (and
which) indexes I will get from that foreach since the results will differ
from the database.

Is there a way around this ?