I have a PHP application that will on occasion have to handle URLs where more than one parameter in the URL will have the same name. Is there an easy way to retrieve all the values for a given key? PHP $_GET returns only the last value.
To make this concrete, my application is an OpenURL resolver, and may get URL parameters like this:
ctx_ver=Z39.88-2004
&rft_id=info:oclcnum/1903126
&rft_id=http://www.biodiversitylibrary.org/bibliography/4323
&rft_val_fmt=info:ofi/fmt:kev:mtx:book
&rft.genre=book
&rft.btitle=At last: a Christmas in the West Indies.
&rft.place=London,
&rft.pub=Macmillan and co.,
&rft.aufirst=Charles
&rft.aulast=Kingsley
&rft.au=Kingsley, Charles,
&rft.pages=1-352
&rft.tpages=352
&rft.date=1871
(Yes, I know it's ugly, welcome to my world). Note that the key "rft_id" appears twice:
rft_id=info:oclcnum/1903126rft_id=http://www.biodiversitylibrary.org/bibliography/4323
$_GET will return just http://www.biodiversitylibrary.org/bibliography/4323, the earlier value (info:oclcnum/1903126) having been overwritten.
I'd like to get access to both values. Is this possible in PHP? If not, any thoughts on how to handle this problem?
$_SERVER['QUERY_STRING']yourself and for non-enctype="multipart/form-data"POST requests you can parsefile_get_contents("php://input"). For POST requests withenctype="multipart/form-data"the submitted data needs to be modified to include[]at the end of the parameter name or the data is lost always. PHP cannot handle that case due brain damaged API to the data!