Query string problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    Query string problem

    Hi.. I have a following query string.

    name=abc&name=d ef&name=jhu

    So all the names are same

    So now i am exploding and imploding string.

    is there a better way to handle
    name=abc
    name=def
    name=jhu

    Regards
    Dheeraj Joshi
  • dgreenhouse
    Recognized Expert Contributor
    • May 2008
    • 250

    #2
    That won't work.
    You'll need to create an array
    i.e.
    Code:
    <html>
    <body>
    <?php
      if (isset($_POST['submit'])) {
        print '<pre>';
        print_r($_POST);
        print '</pre>';
      }
    ?>
    <form method="post" action="">
    <input type="text" name="name[]">
    <input type="text" name="name[]">
    <input type="text" name="name[]">
    <input type="submit" name="submit" value="Show Names Array">
    </body>
    </html>
    
    // Output is:
    Array
    (
        [name] => Array
            (
                [0] => abc
                [1] => def
                [2] => jhu
            )
    
        [submit] => Show Names Array
    )

    Comment

    Working...