Is it possible to pass a javascript array through GET and access it through $_GET at the other end..? Is it possible to pass a javascript array through GET and access it through $_GET at the other end..? arrays arrays

Is it possible to pass a javascript array through GET and access it through $_GET at the other end..?


You can also use JSON (JS parser here)

JS:

  var arr = [1, 4, 9];  var url = '/page.php?arr=' + JSON.stringify(arr);  window.location.href = url;

PHP:

$arr = isset($_REQUEST['arr']) ? json_decode($_REQUEST['arr']) : array();


you need to change your url to be:

nextPage.php?arr[]=js&arr[]=js2

for example.

var_dump($_GET);

outputs: array(1) { ["arr"]=> array(2) { [0]=> string(2) "js" [1]=> string(3) "js2" } }