<?php
$userdb = array(
array(
'uid' => '100',
'name' => 'Sandra Shush',
'pic_square' => 'urlof100'
),
array(
'uid' => '5465',
'name' => 'Stefanie Mcmohn',
'pic_square' => 'urlof100'
),
array(
'uid' => '40489',
'name' => 'Michael',
'pic_square' => 'urlof40489'
)
);
function find_user($userdb, $attributes) {
foreach ($userdb as $key => $user) {
if (empty(array_diff($attributes, $user))) return $key;
}
return false;
}
echo find_user($userdb, array('name' => 'Stefanie Mcmohn', 'uid' => 5465));
preferences:
25.26 ms | 404 KiB | 5 Q