galvin Posted January 2, 2010 Share Posted January 2, 2010 Very simple, I know but I'm out of practice.... How can I EFFICIENTLY write code to redirect users with a userid of 1 thru 10? For example, the code below redirects the person with a userid of 1... if ($_SESSION['userid'] == '1') { redirect_to("index.php"); } But I'd have to write the following for MULTIPLE userids... if ($_SESSION['userid'] == '1' || $_SESSION['userid'] == '2' || $_SESSION['userid'] == '3' || $_SESSION['userid'] == '4' ***AND SO ON THRU 10***) { redirect_to("index.php"); } There has to be a more efficient way to write that, right? I guess I'd have to loop through it? Quote Link to comment https://forums.phpfreaks.com/topic/186975-efficiently-redirecting-multiple-userids/ Share on other sites More sharing options...
PFMaBiSmAd Posted January 2, 2010 Share Posted January 2, 2010 in_array Quote Link to comment https://forums.phpfreaks.com/topic/186975-efficiently-redirecting-multiple-userids/#findComment-987349 Share on other sites More sharing options...
galvin Posted January 3, 2010 Author Share Posted January 3, 2010 that'll work, thank you! Quote Link to comment https://forums.phpfreaks.com/topic/186975-efficiently-redirecting-multiple-userids/#findComment-987396 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.