in_array w/statement
| From: | Sebastian | Date: | Thu, 16 Dec 2004 18:33:22 +0000 |
| Subject: | in_array w/statement | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-204522@lists.php.net to get a copy of this message | ||
Hi,
I cannot solve this problem,. sorry if this looks confusing,.
i have a form and don't want to set the variable if the in_array is true..
the code works, up until i add the last !$buddy in the statement, for some
reason it seems to always be true, ... something i'm doing wrong? btw, i
cannot add the in_array to the statement because if the $buddylist is empty
it will generate errors because of the empty implode.
$buddylist = preg_split('/( )+/', trim($userinfo['buddylist']), -1,
PREG_SPLIT_NO_EMPTY);
if($buddylist)
{
$buddy = in_array($uname['uid'], array(implode(',', $buddylist)));
}
if(($uname['uid'] == $ret) || ($uname['uname'] == $recipients2) &&
($uname['uid'] != 11) && !$buddy)
{
$contactoptions = '<option value="'.$uname['uname'].'"
selected>'.$uname['uname'].'</option>';
}
else if(($uname['uid'] != $bbuserinfo['userid']) &&
($uname['uid'] != 11) &&
!$buddy)
{
$contactoptions .= '<option
value="'.$uname['uname'].'">'.$uname['uname'].'</option>';
}