My PHP is rusty and I'm struggling to figure this out. I'm working with forum software (SMF) and can't really tell the value of the variable I'm trying to check.
All members are assigned a post_group e.g Senior Member
Some users are assigned a special group e.g Moderator.
I want to set the variable $memberType to the group if there is one, if not the post_group.
E.g
User is Moderator and Senior Member. $memberType = 'Moderator'
User is just Junior Member. $memberType = 'Junior Member'
Here's what I've tried:
$memberType = is_null($message['member']['group']) ? $message['member']['group'] : $message['member']['post_group'];
I also tried empty() and isset() instead of is_null but none of them seem to get me a consistent result.
is_null only applies the post_group, empty() only applies the post_group but weirdly not for my "newbie" class. isset() only applies the post.
Any way I can get a consistent result?
$message['member']['group']to$message['member']['group']if$message['member']['group']isnull, it doesn't make any sense to me. are you sure you don't want!is_null?$memberType = isset($message['member']['group']) ? $message['member']['group'] : $message['member']['post_group'];. Now the code says "Is a group set? YES, then assign the group, if there is no group set use the post_group"