Here's another quickie I'm sure there's an elegant solution for, but I
can't think of it.
Salient points:
I have three multidimensional arrays, results of three seperate queries.
No query has a complete list of keys. You would need to do something
like array_merge_unique() on all the keys to get a complete, unique list.
In this case, the user can be present in one or more of these result sets.
They all share a unique key (user_id), but that key may not be present
in any individual result set (array).
I need to merge the data from all three result sets into a single array,
but array_merge isn't the right approach.
Table 1:
user id | score
array(
[0] => array(
['user_id'] =>10,
['score']=>200),
[1] => array(
['user_id'] => 20,
['score'] => 2000),
[2] => array(
['user_id] => 22,
['score'] => 10000)
);
Table 2:
user id | deaths
array(
[0] => array(
['user_id'] => 10,
['deaths'] => 2),
[1] => array(
['user_id'] => 15,
['deaths'] => 8),
[2] => array(
['user_id'] => 22,
['deaths'] => 1)
);
Table 3:
user id | kills
array(
[0] => array(
['user_id'] => 10,
['kills'] => 12),
[1] => array(
['user_id'] => 22,
['kills'] => 4)
)
The end result would look like:
array(
[0] => array(
['user_id'] => 10,
['deaths'] => 2,
['kills'] => 12,
['score'] => 200),
[1] => array(
['user_id'] => 15,
['deaths'] => 8),
[2] => array(
['user_id'] => 20,
['score'] => 2000),
[3] => array(
['user_id'] => 22,
['kills'] => 4,
['deaths'] => 1,
['score'] => 10000)
)
The PHP_mySQL group is dedicated to learn more about the PHP_mySQL web database
possibilities through group learning.
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php_mysql/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/