Raised This Month: $ Target: $400
 0% 

breaking up an if statement into multiple if statements?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 04-05-2009 , 15:18   Re: breaking up an if statement into multiple if statements?
Reply With Quote #5

A switch is better to use when you have if statements like this:

PHP Code:
if ( == 
    
//do something
else if ( == )
    
//do something 
else if ( == )
    
//do something 
If you have multiple if checks it is better to use a switch statement.

PHP Code:
switch ( var )
{
    case 
1//do something
    
case 2,3,4
    {
        
//do stuff
    
}
    case 
5//do something
    
case 6,7,8//do stuff
    
default: //Nothing hit, do stuff

__________________
Bugsy is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:17.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode