|
Posted by Michael Trausch on 04/01/06 08:02
Chris H wrote:
> I have been looking through this script and came across something that I
> dont quite understand how it functions or is used. Basically its brackets
> that are added on at the end of a form field value.
>
> EXAMPLE:
> <input name="eid[]" type="hidden" id="eid[]" value="<? echo $ses_id; ?>">
>
> in other words what does the [] brackets pass to the function thats
> processing the form, basically how is the [] used.
>
PHP sees these types of variables upon submission, and counts them as
variables. You can have twenty items named eid[] and, when the user
presses the Submit button, PHP gets them in $_POST[] as an array. So,
in this case, it would be $_POST['eid'][0] through whatever is the
highest element of the array.
It makes for things that just aren't possible (well, they are possible,
but very tedious to do) without using array functionality in HTML forms.
http://www.webmasterworld.com/forum88/1204.htm is a start, but you can
find a whole world more of information from Google.
You can also explicitly name arrays within your HTML code and PHP will
get them and do the "right thing" with them when the request is sent.
It's actually quite nice.
HTH,
Mike
Navigation:
[Reply to this message]
|