Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to pass an array?

How could I pass an array with PHP by GET method?

Thanks

like image 544
Gero Avatar asked Jun 16 '26 09:06

Gero


1 Answers

In your query string (or POST data, it doesn't really matter), you should end up with this:

http://example.com/myscript.php?foo[]=1&foo[]=2&foo[]=3

PHP will parse that into $_GET["foo"], and it will be an array with the members 1, 2, and 3. How you mangle that from a form is up to you. In the past, I've named different checkboxes "check[]", for example.

like image 54
Jed Smith Avatar answered Jun 18 '26 23:06

Jed Smith



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!