I have a strange problem. I recently migrated my application from my local xampp installation to SUSE Enterprise Server 11 and everything works, but this one thing is driving me crazy and I cannot find a solution.
When passing arrays via GET or POST using this syntax:
search_dggs.php?latmin[]=52.447529&latmin[]=22&lonmin=17.56&lonmax=22.16
I get only the first latmin element. Keep in mind that this is just a simple example that I tried after an error occurred in other places where array transfer is needed.
print_r($_SERVER["QUERY_STRING"]);
exits
latmin[]=52.447529&latmin[]=22&lonmin=17.56&lonmax=22.16
but
print_r($_GET);
gives
Array ( [latmin] => Array ( [0] => 52.447529 ) [lonmin] => 17.56 [lonmax] => 22.16 )
Likewise, with all POST requests.
I am using PHP version 5.3.8. I think the problem is in some server configuration, but I could not find anything about this problem.
Reply to comments:
The same thing happens if I send any number of variables.
parse_str($_SERVER["QUERY_STRING"]); print_r($latmin);
gives
Array ( [0] => 52.447529 )
php.ini can be found here
You should see the behavior in action here.
The source file for this php file is
<?php $test="latmin[]=52.447529&latmin[]=22&lonmin=23&lonmax=22.16"; parse_str($test); print_r($latmin); phpinfo(); ?>
arrays post php get
cpaulik
source share