0

Possible Duplicate:
How to pass an array via $_GET in php?

So I have a script which receives a $_POST with var Board[] containing an array of IDs.

I realized when adding ShareThis to the pages that folks wanting to share the result set would send an invalid link.

I definitely can add a delimited parameter to the script so ShareThis can pass

http://foo.com/bar.php?DelimitedBoard=3|4|5.

My question is whether there is a way to do this using the current Board[] var?

http://foo.com/bar.php?Board[]=3,4,5 fails. Is there a way?

Community
  • 1
  • 1
jerrygarciuh
  • 21,158
  • 26
  • 82
  • 139

3 Answers3

3

Sure, just do:

http://foo.com/bar.php?Board[]=3&Board[]=4&Board[]=5
davidethell
  • 11,708
  • 6
  • 43
  • 63
2

What you want to do is something like this:

http://foo.com/bar.php?Board[]=3&Board[]=4&Board[]=5

Then, if you print_r($_GET['Board']); in bar.php, you will get something like:

Array (
  [0] => 3
  [1] => 4
  [2] => 5
)
DaveRandom
  • 87,921
  • 11
  • 154
  • 174
1

Number array serialization is very easy. Use join(',', $Board) to form a comma-separated ID string, use explode(',', $_GET["Board"]) to get the array back.

Seva Alekseyev
  • 59,826
  • 25
  • 160
  • 281