Jump to content

PHP Array quick help


Gayner

Recommended Posts

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

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

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.