Re: different vars with the same name

From: Date: Sun, 03 Dec 2000 08:13:34 +0000
Subject: Re: different vars with the same name
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-28412@lists.php.net to get a copy of this message
Hi, try: /myscript.php?var1[]=hello&var1[]=bye This should create a zero based array named var1 so you can access them var1[0], var1[1] etc.... -- Meir Kriheli MKsoft computer systems 'There's someone in my head but it's not me" - Pink Floyd > hi! > > > my script receive two vars with the same name but i can only access the > last one. In this example i use the gets method but in fact i must use > the POST method (i thought that my problem would be more easy to explain > with the gets method with my limited english...): > > > /myscript.php?var1=hello&var1=bye > > > In ASP i can access both vars this way: > > x = Request.QueryString("var1")(1) 'x contains "hello" > y = Request.QueryString("var1")(2) 'y contains "bye" > > > In PHP i can only get the value of the last var: > > 1. $x = $HTTP_GET_VARS["var1"]; // $x contains only "bye" > > 2. $x = $HTTP_GET_VARS["var1"][0]; // $x contains "b" > $x = $HTTP_GET_VARS["var1"][1]; // $x contains "y" > $x = $HTTP_GET_VARS["var1"][2]; // $x contains "e" > > > any idea? > > > thanks in advance, > Galfano Carboni

« previous php.general (#28412) next »