Gayner Posted November 30, 2009 Share Posted November 30, 2009 I need $_SESSION{'username'} to be like this: if $_SESSION['username'] = "gayner,bob,jesus"; echo "ba blah "; but do i use Arrays or what for those 3 nameS? how thx Link to comment https://forums.phpfreaks.com/topic/183395-php-array-quick-help/ Share on other sites More sharing options...
trq Posted November 30, 2009 Share Posted November 30, 2009 Your question is about as clear as mud. You can if you like store a string.... $_SESSION['username'] = "gayner,bob,jesus"; or an array..... $_SESSION['username'] = array("gayner","bob","jesus"); Its up to you. Link to comment https://forums.phpfreaks.com/topic/183395-php-array-quick-help/#findComment-967998 Share on other sites More sharing options...
zeodragonzord Posted November 30, 2009 Share Posted November 30, 2009 Your goal is to check if the user in the session is either "gayner" "bob" or "jesus" correct? If so, you'll want to do this. $ALLOWED = array("gayner","bob","jesus"); if(in_array($_SESSION['username'], $ALLOWED)) { //do something here } See in_array(needle, haystack): http://php.net/manual/en/function.in-array.php Link to comment https://forums.phpfreaks.com/topic/183395-php-array-quick-help/#findComment-968285 Share on other sites More sharing options...
Gayner Posted November 30, 2009 Author Share Posted November 30, 2009 Your goal is to check if the user in the session is either "gayner" "bob" or "jesus" correct? If so, you'll want to do this. $ALLOWED = array("gayner","bob","jesus"); if(in_array($_SESSION['username'], $ALLOWED)) { //do something here } See in_array(needle, haystack): http://php.net/manual/en/function.in-array.php That's what i wanted, thank u sir iuno why guy posted other code toc onfuse me? Link to comment https://forums.phpfreaks.com/topic/183395-php-array-quick-help/#findComment-968544 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.