Re: Help retrieving an HTML array

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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 nothing
echo $xname[0] ; // this returns only first digit of the first input
None of the above seem to recognize that xname is ( in HTML ) an array .

Because 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.








On Sun, 2005-10-02 at 19:38, adriano ghezzi wrote:

if 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@xxxxxxxxx>:

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





--
John C. Nichel IV
Programmer/System Admin (ÜberGeek)
Dot Com Holdings of Buffalo
716.856.9675
jnichel@xxxxxxxxxxxxxxxxxxxxxxxxxxx

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux