SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Darren884's Avatar
    Join Date
    Aug 2003
    Location
    Southern California, United States
    Posts
    1,616
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Easy question maybe

    How would I make an array of the same variable
    like i want settings_1 settings_2 settings_3 etc... into 1 variable.
    Have a good day.

  2. #2
    SitePoint Wizard
    Join Date
    Aug 2004
    Location
    California
    Posts
    1,672
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Look in the manual at implode() and explode().

  3. #3
    SitePoint Wizard cranial-bore's Avatar
    Join Date
    Jan 2002
    Location
    Australia
    Posts
    2,634
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There are a couple of ways to create an indexed array.
    PHP Code:
     //first method
     
    $var = array('value1''value2''value3');
     
     
    //second method
     
    $var[] = 'value1';
     
    $var[] = 'value2';
     
    $var[] = 'value3'
    Both methods will create the variable $var which is an array with the 3 values.
    This will create an indexed array where each array element is identified by a number (starting with 0).

    Continuing from above:
    PHP Code:
     echo $var[0]; //outputs value1
     
    echo $var[1]; //outputs value2
     
    echo $var[2]; //outputs value3 


Bookmarks

Posting Permissions

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