Go Back   CodingForums.com > :: Server side development > PHP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-20-2008, 12:24 AM   PM User | #1
Dat
Regular Coder

 
Join Date: Oct 2007
Posts: 147
Thanks: 28
Thanked 0 Times in 0 Posts
Dat is an unknown quantity at this point
array default value

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
PHP Code:
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.
Dat is offline   Reply With Quote
Old 07-20-2008, 01:30 AM   PM User | #2
p4plus2
Regular Coder

 
Join Date: Mar 2008
Posts: 103
Thanks: 1
Thanked 8 Times in 8 Posts
p4plus2 is an unknown quantity at this point
PHP Code:
$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

p4plus2 is offline   Reply With Quote
Old 07-20-2008, 05:05 AM   PM User | #3
oesxyl
Master Coder


 
Join Date: Dec 2007
Posts: 6,682
Thanks: 436
Thanked 890 Times in 879 Posts
oesxyl is a jewel in the roughoesxyl is a jewel in the roughoesxyl is a jewel in the rough
PHP Code:
$keys array_keys($TEMPLATE);
$values array_fill(0,count($keys),true);
$TEMPLATE array_combine($keys,$values); 
corect syntax is how p4plus2 said.

regards

Last edited by oesxyl; 07-20-2008 at 05:26 AM.. Reason: corrected
oesxyl is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:58 PM.


Advertisement
Log in to turn off these ads.