Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Dat
    Dat is offline
    Regular Coder
    Join Date
    Oct 2007
    Posts
    147
    Thanks
    28
    Thanked 0 Times in 0 Posts

    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.

  • #2
    Regular Coder
    Join Date
    Mar 2008
    Posts
    103
    Thanks
    1
    Thanked 8 Times in 8 Posts
    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


  • #3
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •