aki
aki

Reputation: 1241

sending arrays in _GET in php

php gives the ability to send arrays from the _GET.

example:

test.php?var1=abc&arr[0]=1&arr[3]=test

will output:

Array
(
    [var1] => abc
    [arr] => Array
        (
            [0] => 1
            [3] => test
        )

)

is this consider bad coding?

Upvotes: 11

Views: 308

Answers (3)

dmitry
dmitry

Reputation: 5039

No, it's usual practice. Also it's natural practice for sending selects with size greater than one.

Upvotes: 17

Jan Dragsbaek
Jan Dragsbaek

Reputation: 8101

Yes, it is a bad thing to do, and its also really bad for your websites SEO. It quickly gets really confusing if you put too much in the querystring. Keep it Simple!

Upvotes: -1

Naftali
Naftali

Reputation: 146300

No.

That looks fine.

You can even do:

test.php?var1=abc&arr[]=1&arr[]=test

Which would output:

Array
(
    [var1] => abc
    [arr] => Array
        (
            [0] => 1
            [1] => test
        )

)

Upvotes: 3

Related Questions