Embedded Array

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Andy Lee

    Embedded Array

    Hi

    I have a form sending a variable 'details' as a hidden field :

    The details variable value (set in the html) is : -
    Q1=A1&Q2=A2&Q3= A3 ........

    When php requests this string - i would like it to turn it into an array.
    As you can see, it is already similar to the HTTP Querystring format.

    How can i turn it into an array.

    Thanks

    AL



  • Andy Hassall

    #2
    Re: Embedded Array

    On Sat, 15 May 2004 19:35:22 +0100, "Andy Lee" <no_email@no_em ail.com> wrote:
    [color=blue]
    >Hi
    >
    >I have a form sending a variable 'details' as a hidden field :
    >
    >The details variable value (set in the html) is : -
    >Q1=A1&Q2=A2&Q3 =A3 ........
    >
    >When php requests this string - i would like it to turn it into an array.
    >As you can see, it is already similar to the HTTP Querystring format.
    >
    >How can i turn it into an array.[/color]

    $details = array();
    foreach (explode("&", $_POST['details']) as $value) {
    $value = explode("=", $value);
    $details[$value[0]] = $value[1];
    }

    --
    Andy Hassall <andy@andyh.co. uk> / Space: disk usage analysis tool
    http://www.andyh.co.uk / http://www.andyhsoftware.co.uk/space

    Comment

    • Chung Leong

      #3
      Re: Embedded Array

      "Andy Lee" <no_email@no_em ail.com> wrote in message
      news:Oqtpc.3491 3$pk2.4850@path ologist.blueyon der.net...[color=blue]
      > Hi
      >
      > I have a form sending a variable 'details' as a hidden field :
      >
      > The details variable value (set in the html) is : -
      > Q1=A1&Q2=A2&Q3= A3 ........
      >
      > When php requests this string - i would like it to turn it into an array.
      > As you can see, it is already similar to the HTTP Querystring format.
      >
      > How can i turn it into an array.[/color]

      Use parse_str($stri ng, $array).


      Comment

      Working...