...

View Full Version : array default value



Dat
07-20-2008, 12:24 AM
How can I get $TEMPLATE's default value as true;

So that later when I create $TEMPLATE[USER_CAN_EDIT] = false;

I can use that later with

if (TEMPLATE[USER_CAN_EDIT] == true)
{
//Something
}
else if (TEMPLATE[USER_CAN_EDIT] == false)
{
//Something else
}

I want all of the array's of $TEMPLATE's value to be true as default; so when if i were to change them later I can do what is above.

p4plus2
07-20-2008, 01:30 AM
$TEMPLATE[USER_CAN_EDIT] = true;
//code here that can change to false if user can not edit.
if ($TEMPLATE[USER_CAN_EDIT] == true){
//Something
}
elseif ($TEMPLATE[USER_CAN_EDIT] == false){
//Something else
}

oesxyl
07-20-2008, 05:05 AM
$keys = array_keys($TEMPLATE);
$values = array_fill(0,count($keys),true);
$TEMPLATE = array_combine($keys,$values);


corect syntax is how p4plus2 said.

regards



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum