How to pass an array via $_GET in php?

In PHP, arrays can be passed in the URL using the $_GET superglobal variable, but they need to be encoded first using the http_build_query() function. Here is an example:

<?php

$array = ["item1" => "value1", "item2" => "value2", "item3" => "value3"];
$query = http_build_query($array);
$url = "example.com/script.php?" . $query;

echo $url;

In this example, the array is encoded into a query string format and then appended to the URL. The resulting URL would look like this:

example.com/script.php?item1=value1&item2=value2&item3=value3

Then, in the script that the URL points to, you can access the array using the $_GET superglobal variable:

$item1 = $_GET["item1"];
$item2 = $_GET["item2"];
$item3 = $_GET["item3"];

Note that encoding arrays in the URL using the $_GET method should be used with caution, as it can make the URL very long and difficult to read. It is also not secure as it can be read by anyone who can access the url.

Consider using POST method instead if you are passing sensitive information.