Re: Help retrieving an HTML array
| From: | John Nichel | Date: | Wed, 01 Feb 2006 16:42:33 +0000 |
| Subject: | Re: Help retrieving an HTML array | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-229651@lists.php.net to get a copy of this message | ||
Please don't hijack threads.
Mauricio Pellegrini wrote:
Hi , I have a HTML page with a form in which there are some inputs like these: input type=text name=xname value="3303" input type=text name=xname value="9854" .... input type=text name=xname value="n..." the name of the input is always the same ( xname ) This generates automatically generates an array named xname in HTML with all the diferent values assigned to a diferent position.This will NOT automatically generate an array. 'xname' will be equal to the last one sent in the post. If you want an array, name your form fields as such, 'xname[]'
My question is : How do I retrieve that array from within PHP ? I've tryed the following $xname=$_REQUEST['xname']; and then echo $xname[0][0] ; // this returns nothingBecause it isn't. Name your fields the way I've shown above, and you can access them as an array.... $_REQUEST['xname'][0] $_REQUEST['xname'][1] $_REQUEST['xname'][2] So on, and so forth.echo $xname[0] ; // this returns only first digit of the first inputNone of the above seem to recognize that xname is ( in HTML ) an array .
On Sun, 2005-10-02 at 19:38, adriano ghezzi wrote:-- John C. Nichel IV Programmer/System Admin (ÜberGeek) Dot Com Holdings of Buffalo 716.856.9675 jnichel@dotcomholdingsofbuffalo.comif i understand well you need to get an array from html post if you use the same name for your html fields you automatically have an array in $_POST eg input type=text name=myfield value="field_1" input type=text name=myfield value="field_2" you'll get the array ar_myfield = $_POS['myfield'] you should achieve the same result using myfield[key] in the name of html hyh by ag. 2005/10/2, Martin van den Berg <martinvdberg@gmail.com>:Newbe question: How does one convert an array into a HTML GET request easely? Are there any standard functions? Same for HTML POST requests. Thanks, Martin. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php