I have a list of users on a webpage and am trying to compare each username with a list of users in an array. But for some reason the following code always returns false. Some usernames do match and should therefore display a yes next to the username.
foreach($result AS $user){
foreach($listarray AS $name){
if($user['username'] == $name){
$whitelisted = 'Yes';
} else {
$whitelisted = 'No';
}
}
echo '<tr><td><p>'.$user['username'].'</p></td><td><p>'.$user['location'].'</p></td><td><p>'.$user['date_joined'].'</p></td><td><p>'.$whitelisted.'</p></td>';
}
Why is this comparison returning false even when some names should match?