RE: Differences in arrays

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

 



To view the terms under which this email is distributed, please go to http://disclaimer.leedsmet.ac.uk/email.htm



On 02 December 2004 10:26, Stuart Felenstein wrote:

> I have arrays set up in a user form.  One type is from
> a multi-select list.

[....]

> I have 3 textfield elements all named school[]

[....]

> 2- Why would the second array behave differently then the first ?

Because you're using different input types.

A multi-select list sends exactly one value (array element) for each value
selected, so you will always get exactly the same number of array elements
as there were items selected (including possibly none).

Each text element sends its value (hence an array element) unconditionally,
because each is treated separately  -- there's no grouping of like-named
boxes for textboxes like there is for radio buttons.  This means you'll
always see 3 school[] elements, even if some are empty.  Note that this
makes it possible for (say) boxes 1 and 2 to be empty, but box 3 contain a
value, or boxes 1 and 3 to contain values but box 3 be empty -- you may need
to adjust your code to allow for this!

Cheers!

Mike

---------------------------------------------------------------------
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning & Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Headingley Campus, LEEDS,  LS6 3QS,  United Kingdom
Email: m.ford@xxxxxxxxxxxxxx
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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