|
Posted by Sandman on 02/01/07 10:35
Hi,
So I have 2 arrays:
one contains userids. It may look like:
user_id[0] => 12,
user_id[1] => 30,
user_id[2] => 43
The other is a multi-dimensional array with fields like:
user_info [0] => Array
(
[user_id] => 13
[user_flag] => 1
[url] => http://www.example.com?index,0
)
user_info[1] => Array
{
Array
(
[user_id] => 120
[user_flag] => 1
[address] => 1234 Main St, Anytown, USA
[url] => http://www.yahoo.com
)
user_info[2] => Array
{
Array
(
[user_id] => 130
[user_flag] => 1
[address] => 134 Main St, Anytown, USA
[url] => http://www.google.com
)
I need to find all elements in user_info, where user_info[]['user_id']
== user_id[] for every element of user_id.
Is there a quick and easy function to do this? My current loop looks
like:
for ($i=0; $i<count($user_id); $i++) {
for ($j=0; $j<=count($user_info); $j++) {
if ($user_info[$j]["user_id"] == $user_id[$i]) {
$newarray[$i] = $user_info[$j];
break;
}
}
}
This is crappy though and I'd love to speed it up. Suggestions
welcome.
Thanks!
EL
[Back to original message]
|