Sunday 3 February 2013

Passing a named associative array via URL

Problem:

How do I manually pass an associative array via URL?

Solution:

Let's say we have an associative array named 'arr_args' with the key-value pairs 'key1'=>'value1', 'key2'=>'value2', i.e. arr_args = [key1=>value1, key2=>value2]. Let's also assume we have a sample script called 'sample.php' that will be receiving this associative array.

One way that you can pass this into a URL as the following:

sample.php?arr_args[key1]=value1&arr_args[key2]=value2

No comments:

Post a Comment