PDA

View Full Version : Array variable


Jolten
08-07-2005, 06:11 PM
Hi,

I've got this code in a php file
(!in_array($bbuserinfo['usergroupid'], array(6,2,11,12,7,5,14,15,18)))

It works great. What I'm wondering is if I can assign a variable to the array similar to:


$good = "6,2,11,12,7,5,14,15,18";

if ((!in_array($bbuserinfo['usergroupid'], array($good))) {

blah

} else {

blah blah

}


will work just as good? I can't seem to get the variable to carry into the array.

This is mainly to allow me to alter usergroup settings once per page rather than having to hunt down several lines of code with the array in it.

Okay I answered my own question.


$good = array(6,2,11,12,7,5,14,15,18);

if ((!in_array($bbuserinfo['usergroupid'], $good))) {

blah

} else {

blah, blah

}


works.

sabret00the
08-08-2005, 09:41 AM
you could try implode();

Logikos
08-08-2005, 10:26 AM
Okay I answered my own question.

Hate when that happens. ^^