Captain's Universe Home
Captain's Universe Home
Cosmic Ray Muon DetectorTeleGarden Pages
Time on MarsBryophyllum Plants
Jupiter Radio AstronomyAncient Pages
Salzburg Tourist GuideEarth Magnetometer
  H O M E     AJAX & MORE     LINUX & MORE     RTAI     XENOMAI     ADEOS IPIPE      
    JAVA & BROWSERS     *NIX     ELECTRONICS     REVIEWS     ARTEMIA     FAIRY SHRIMP      



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

Google
 
Web www.captain.at
go to top
© 1996-2010 . All rights reserved.
No reproduction, distribution, publishing or transmission of the copyrighted materials at this site is permitted. Policy
go to top