jeudi 10 novembre 2016

Passing arrays in the URL - compatible with standars and all browsers

I want to to pass parameters of a variable by GET (and not by POST), to comply SEO-URL-friendly methodology. Let's say that

$models = array( 5000, 6001, 7777);

so I would pass the parameters like this:

http://www.example.com/gallery-display/?models%5B%5D=5000&models%5B%5D=6001&models%5B%5D=7777

In that way I can retrieve the values directly by:

 $models = $_GET['models'];
 print_r($models);

Alternatives of using char separator like pipeline "|" and

http://www.example.com/gallery-display/?models=5000|6001|7777

and retrieving the data by

$models = explode("|", $_GET['models']);
print_r($models);

is not desired, for reasons not confessable here.

Is the first one a reliable method, does it comply with standars and can be trusted in any decent modern web broswer?




Aucun commentaire:

Enregistrer un commentaire