Re: Getting at $_POST values using a loop
| From: | zbranigan | Date: | Mon, 23 Jun 2003 16:37:27 +0000 |
| Subject: | Re: Getting at $_POST values using a loop | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-152511@lists.php.net to get a copy of this message | ||
>>>>> "Dave" == Dave Alger <news@alger2000.freeserve.co.uk> writes:
Dave> Hi all, This one is causing me a few headaches. How should I
Dave> be doing this?
Dave> On my previous page I've created a series of fields using a
Dave> loop so that a field is created like this:
Dave> echo "<hr>$fieldname:<input name='Field$n'
Dave> maxlength='25'>";
Here's a way to do it so that the field numbers are not required to be
contiguous. You don't really have to copy $_POST to $myPostVars
except that, in the code from which this snippet was extracted, there
are further processing steps which depend on the fact that none of the
form variables left in $myPostVars have been processed yet.
,----
|
| $myPostVars= $_POST;
|
| reset ($myPostVars);
| while (list ($key, $val) = each ($myPostVars)) {
| if (preg_match("/^Field[0-9]+", $key )) {
| list($i)= sscanf($key, "Field%d");
| FieldAry[$i]= $val;
| unset($myPostVars[$key]);
| }
| }
`----
--
no toll on the internet; there are paths of many kinds;
whoever passes this portal will travel freely in the world