Jump to content

[SOLVED] arrays on == ¿


Monkuar

Recommended Posts

if ($member['id'] == 1)
        {
            $this->output = preg_replace( "/<!--interests-->/e", "\$this->html->interests(\$info)", $this->output );

        }

 

I want to beable to put more then just 1 right  there

 

Member id 1 and 2 should see the output too!

 

So how would i do  like this??

 

if ($member['id'] == 1,2)

 

 

or ?

 

if ($member['id'] == 1|2)

 

 

??Thx

Link to comment
Share on other sites

if you plan on making that list of numbers grow, it would be better for you to do this:

 

$memberIds = array('1','2');
if(in_array($member['id'],$memberIds)) {
  // stuff here
}

 

That way you can just add to the array the single id instead of having to have this really long condition.  And you can dynamically populate the array.  Can't dynamically populate the condition unless you get into using eval() (which you don't want to do).

Link to comment
Share on other sites

if you plan on making that list of numbers grow, it would be better for you to do this:

 

$memberIds = array('1','2');
if(in_array($member['id'],$memberIds)) {
  // stuff here
}

 

That way you can just add to the array the single id instead of having to have this really long condition.  And you can dynamically populate the array.  Can't dynamically populate the condition unless you get into using eval() (which you don't want to do).

 

Wow thanks abunch u guys are smart!!

Link to comment
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.