/    Sign up×
Community /Pin to ProfileBookmark

Array’s 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

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

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.

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@themartyJul 20.2008 — in your code, you're using a constant. but i guess that is a typying mistake?

You can simple do:

[code=php]
$template = array(
"user_can_edit" => true,
"user_can_do_sth_else" => true
);
[/code]


to set all the defaults and then later overwrite them:

[code=php]
$template['user_can_edit'] = false;
[/code]
×

Success!

Help @arrangements spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.7,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...