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
https://forums.phpfreaks.com/topic/164828-solved-arrays-on-%C2%BF/
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).

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!!

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.