Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.