Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sending arrays in _GET in php

Tags:

arrays

php

get

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?

like image 417
aki Avatar asked Nov 30 '11 14:11

aki


People also ask

Can PHP send array request get?

You can pass an associative array to http_build_query() and append the resulting string as the query string to the URL. The array will automatically be parsed by PHP so $_GET on the receiving page will contain an array.

Can you send array in post?

Postman allows anyone to send any kind of array with their request, you just need to know how.

Is $_ POST an array?

The PHP built-in variable $_POST is also an array and it holds the data that we provide along with the post method.

How do I pass an array from one page to another in PHP?

You can use session, save the value in session and in another page where you want the array you get the value from the session. You can implode the array value using any specific special character and send the value to where you want then get the value in that page then explode the value.


1 Answers

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

like image 74
dmitry Avatar answered Sep 23 '22 12:09

dmitry