Jump to content

Help Global Array...


MLBPlayer

Recommended Posts

I am trying to make this work so I can use a global function for my Moderator List.

$rofl = "test,lol";
$moderators = array($rofl);
if (in_array(strtolower($_SESSION['user_name']), array_map('strtolower', $moderators))) {
echo "You have access!";
}else{
echo "You do not have access"
}

 

I get the array from my $_SESSION username.

But the above does not work, help?

Link to comment
https://forums.phpfreaks.com/topic/186792-help-global-array/
Share on other sites

$rofl = "test,lol";
$moderators = array($rofl);

 

The above code does not create an array that two entries. It creates an array that has one entry with the value "test,lol". If you want or need to start with a comma separated list, use explode to get it into an array.

Link to comment
https://forums.phpfreaks.com/topic/186792-help-global-array/#findComment-986398
Share on other sites

$rofl = "test,lol";
$moderators = array($rofl);

 

The above code does not create an array that two entries. It creates an array that has one entry with the value "test,lol". If you want or need to start with a comma separated list, use explode to get it into an array.

 

function moderators(){
$str = 'test,two,three,four';
explode(',', $str, 0);
return $str;
}

 

and

 

 

$moderators = array(moderators());
if (in_array(strtolower($_SESSION['user_name']), array_map('strtolower', $moderators))) {

 

It's not working, Help me?

Link to comment
https://forums.phpfreaks.com/topic/186792-help-global-array/#findComment-986400
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.