Results 1 to 5 of 5

Thread: [Resolved] Pass PHP Array in the URL?

  1. #1

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256

    [Resolved] Pass PHP Array in the URL?

    I'm calling a page like this: http://localhost/test.php?a[]=a&a[]=b&a[]=c&a[]=d&a[]=e&a[]=f&a[]=g&a[]=h&a[]=i

    And using this code:

    PHP Code:
        <?php
            
    if (isset($_REQUEST['a'])) {
                if (
    is_array($_REQUEST['a'])) {
                    for (
    $i 0$i count($_REQUEST['a']); $i++) {
                        echo 
    $_REQUEST['a'][$i] . '<br />';
                    }
                }
            }
        
    ?>
    It works perfectly, but I'm wondering if there are any drawbacks to it?

    I've never seen anything do it this way before, so it makes me paranoid that there's something wrong with doing it that way.
    Last edited by The Hobo; Jul 13th, 2004 at 12:56 PM.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Only thing I can think of, is, is there a maximum length for a querystring?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Kitten CornedBee's Avatar
    Join Date
    Aug 2001
    Location
    In a microchip!
    Posts
    11,594
    Nothing wrong, it's a feature of PHP.
    All the buzzt
    CornedBee

    "Writing specifications is like writing a novel. Writing code is like writing poetry."
    - Anonymous, published by Raymond Chen

    Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.

  4. #4

    Thread Starter
    Stuck in the 80s The Hobo's Avatar
    Join Date
    Jul 2001
    Location
    Michigan
    Posts
    7,256
    Cool. Thanks, guys.
    My evil laugh has a squeak in it.

    kristopherwilson.com

  5. #5
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Would it not make more sense to pass complicated data like that by POST instead of GET?
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

Posting Permissions

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



Click Here to Expand Forum to Full Width