Associative Array from input type=text

Discussion in 'PHP' started by liam1412, Oct 7, 2008.

  1. #1
    Hi

    I have a form that has 10 lots of 2 fields

    ie

    url
    text

    url
    text

    I want to add these to an associative array straight from the form.

    Can anytone tell me how this is done.

    Thanks
     
    liam1412, Oct 7, 2008 IP
  2. Sillysoft

    Sillysoft Active Member

    Messages:
    177
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    58
    #2
    Are you talking about when the form gets submitted the fields themselves are taken as arrays? If so perhaps you are looking for this?

    
    <input type="text" name="url[]">
    <input type="text" name="text[]">
    
    Code (markup):
     
    Sillysoft, Oct 7, 2008 IP
  3. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #3
    yep, use the name[].

    You then will be able to access the variables as an array.

    This will work on all form inputs/buttons/etc..

    Peace,
     
    Barti1987, Oct 7, 2008 IP