plintu Posted August 11, 2009 Share Posted August 11, 2009 what would be a more effecient wat to write this? if($ir['location']=='1'){die("You should not be here, you are under aged!");} if($ir['location']=='2'){die("You should not be here, you are under aged!");} if($ir['location']=='3'){die("You should not be here, you are under aged!");} if($ir['location']=='4'){die("You should not be here, you are under aged!");} if($ir['location']=='5'){die("You should not be here, you are under aged!");} if($ir['location']=='6' && $ir['loved']=='3'){die("You got your lovin for today!");} if($ir['location']=='7' && $ir['loved']=='5'){die("You got your lovin for today!");} if($ir['location']=='8' && $ir['loved']=='7'){die("You got your lovin for today!");} if($ir['location']=='9' && $ir['loved']=='10'){die("You got your lovin for today!");} Quote Link to comment Share on other sites More sharing options...
Lithium Posted August 11, 2009 Share Posted August 11, 2009 Re: need a little code effeciency help? $var = array('1','2','3','4','5','6','7','8','9'); $var2 = array('3','5','7','10'); if (in_array($ir['loved'],$var2) && in_array($ir['location'],$var)) { die("You got your lovin for today!"); } else if (in_array($ir['location'],$var)) { die("You should not be here, you are under aged!"); } Not tested but should work Quote Link to comment Share on other sites More sharing options...
plintu Posted August 11, 2009 Author Share Posted August 11, 2009 Re: need a little code effeciency help? $var = array('1','2','3','4','5','6','7','8','9'); $var2 = array('3','5','7','10'); if (in_array($ir['location'],$var2) && in_array($ir['location'],$var)) { die("You got your lovin for today!"); } else if (in_array($ir['location'],$var)) { die("You should not be here, you are under aged!"); } Not tested but should work that is close but it doesn't account for the && $ir['loved']=='3') part. I think I can get it from there, thank you! Quote Link to comment Share on other sites More sharing options...
POG1 Posted August 11, 2009 Share Posted August 11, 2009 Re: need a little code effeciency help? $locations = array( 'allowed' => array(6,7,8,9), 'notAllowed' => array(1,2,3,4,5), 'loved' => array(3,5,7,10) ) if(in_array($ir['location'],$locations['notAllowed'])) die("You should not be here, you are under aged!"); if(in_array($ir['loved'],$locations['loved'])) die("You allready had your lovin today!"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.