@SrWebDeveloperNov 29.2009 — #Unless I'm missing something obvious, in any multiple selection form element there is only one name or id so would you need more than 1D?
Just append [] to the form element name and it ends up as $_POST['name'] as an array after submit, i.e.
Aside from form submission, you can pass arrays of any dimension using session variables from page to page if you wish. Just remember -- unlike a real PHP multidimensional array, $_SESSION keys at the root level must be valid variable names, not numbers.
@NogDogNov 29.2009 — #Within the same domain, the session option suggested above is probably more efficient than sending the data via post. But if you do need to send it via post for some reason (such as a cURL request to another site or something), you can [url=http://php.net/serialize]serialize[/url]() the array and send the resulting string as a single post field, then unserialize() it in the receiving script.
@Mr_Initial_ManauthorNov 29.2009 — #Unless I'm missing something obvious, in any multiple selection form element there is only one name or id so would you need more than 1D?[/QUOTE]
Yes. I am generating an XML page, and what is entered on the form on one page dictates if the generated XML reads:
@opifexNov 29.2009 — #edit: Got distracted while posting so I missed the details, but this should help some anyway.
In general the answer is yes, for example if you have [code=html] <input name="full_name[]" type="text" id="full_name[]" value="<?php echo $value0; ?>" /> <input name="year_salary[]" type="text" id="year_salary[]" value="<?php echo $value1; ?>" /> <input name="job_title[]" type="text" id="job_title[]" value="<?php echo $value2; ?>" /> <input name="co_name[]" type="text" id="co_name[]" value="<?php echo $value3; ?>" /> [/code] and you wanted to pull just the "full_name" you can [code=php] foreach ($_POST['full_name'] as $name) { echo $name."n"; } [/code] and you get Aaron Whistler Jr.
Wendy Buttons[/QUOTE] and if you want to pull the "full_name" AND "year_salary" AND "job_title" AND "co_name" you can do this by using one of them to get the indexes [code=php] for ($i=0; $i < count($_POST['full_name']); $i++) { echo $_POST['full_name'][$i]." earns "; echo $_POST['year_salary'][$i]." per year as "; echo $_POST['job_title'][$i]." at "; echo $_POST['co_name'][$i].".n"; } [/code] and you get Aaron Whistler Jr. earns $1,000,000 per year as assistant mailboy at Whoopee Incorporated.
Wendy Buttons earns $40,000 per year as SysAdmin at WeRtheBest DotCOMM.[/QUOTE]
But, there are other options depending on what you need to do.
@Mr_Initial_ManauthorNov 29.2009 — #I'd serialize vs. using the separator method.[/QUOTE]
How do you do that with a bunch of form names?
@Mr Initial Man
Since you're generating an xml anyway, you're way ahead of the game!
Just parse the xml for your stats box info... no sense in doing more work than you have to.
[I]...or am I missing something?[/I][/QUOTE]
Okay, what's going on is this is part of a larger update setup: guys who know how to do statistics but not XML use the form to in the numbers. The script generates the XML. They send me the XML, and I add it to a larger XML file.
@SrWebDeveloperNov 30.2009 — #How do you do that with a bunch of form names?[/quote]
Refer to reply #3 for command help - If you have XML multi-dimensional array data prior to generating the form serialize it and pass it as one value, the on form submit in your processing script unserialize and you get back the original data.