Re: Passing array to function

From: Date: Tue, 13 Aug 2002 16:52:58 +0000
Subject: Re: Passing array to function
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-112368@lists.php.net to get a copy of this message
You'll find the values accessible in $_POST as $_POST['cgroup_1']['0'], $_POST['cgroup_1']['1'], etc. $_POST itself is an array, and so is your variable. HTH Mike "Bill Hudspeth" <wbhk@unm.edu> wrote in message news:20020813161220.75407.qmail@pb1.pair.com... > I am trying to write a function that builds a multiple-choice drop down > list. As such, I need to specify an array in the name attribute of the > <select> tag. I am trying to pass a parameter to the function which gets > used as this name attribute, but seem to be having problems with the square > brackets. In the example below, I would like to submit the $elementname > variable to a function, but can't get it to take the '[' and ']' characters. > My resultant $_POST[] variable is empty. Any hints? > > > > > > HARD-CODED VERSION > > > > echo "<select name='cgroup_1[]' multiple size='5'>"; > > echo "<option value = '$chon_group_a[1]' > selected>$chon_group_a[1]</option>"; > > echo "<option value = > '$chon_group_a[2]'>$chon_group_a[2]</option>"; > > echo "<option value = > '$chon_group_a[3]'>$chon_group_a[3]</option>"; > > echo "<option value = > '$chon_group_a[4]'>$chon_group_a[4]</option>"; > > echo "</select>"; > > > > file://the $chon_group_a is a locally defined array that does not seem to be > causing any problems > > > > DESIRED FUNCTION VERSION > > > > $elementname="cgroup_1[]"; > > $elementsarray=$chon_group_a; > > PrintOptionBox($elementname,$elementsarray); > > >

« previous php.general (#112368) next »