- CSS - Cascaded Style Sheets



|
|
URL parameter array in PHP - how to pass an array to PHP
There are plenty of pages out there describing how to pass an array to some server-side script. Most of
them describe a single parameter, which will contain every value separated by some character.
mysite.com/index.php?parameter=1,2,5,3
...and in the server-side script you do some splitting:
$array = split(",", $_GET{parameter});
But there is another method:
You can pass the array this way:
mysite.com/index.php?parameter[]=1¶meter[]=2¶meter[]=5¶meter[]=3
Granted, the URL is longer, but this has the advantage, that $_GET{parameter} is an array from the
beginning of the script and you don't need to do any splitting:
print_r($_GET);
Array
(
[parameter] => Array
(
[0] => 1
[1] => 2
[2] => 5
[3] => 3
)
)
Last-Modified: Sat, 04 Feb 2006 16:03:04 GMT
|
|