Jump to content

[SOLVED] else IF?


Monkuar

Recommended Posts

if ($cur_post['group_id'] == '1') {
    $user_info[] = '<br>Group'.': Admin';
} else if ($cur_post['group_id'] == '2') {
    $user_info[] = '<br>Group'.': Members';
}

 

However, if you are doing more than just two options, you should be using a switch() statement

switch ($cur_post['group_id'])
{
    case '1':
        $user_info[] = '<br>Group'.': Admin';
        break;
    case '2':
        $user_info[] = '<br>Group'.': Members';
        break;
    case '3':
    default:
        $user_info[] = '<br>Group'.': Somethign Else';
        break;

}

Link to comment
https://forums.phpfreaks.com/topic/165981-solved-else-if/#findComment-875434
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.