how to pass an array in GET in PHP?

If you want to pass an array as parameter, you would have to add a parameter for each element. Your query string would become:

?arr[]=1&arr[]=2&arr[]=3&arr[]=4

As others have written, you can also serialize and unserialize the array.

But do you really have to send the data to the client again? It looks like you just need a way to persist the data between requests.

In this case, it is better imo to use sessions(docs). This is also more secure as otherwise the client could modify the data.

Leave a Comment