Re: Cleaner way to do this?
| From: | Marek Kilimajer | Date: | Thu, 02 Dec 2004 17:26:45 +0000 |
| Subject: | Re: Cleaner way to do this? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-203367@lists.php.net to get a copy of this message | ||
Robert Sossomon wrote:
foreach ( $_POST as $key => $value ) { while ($key != "submit") { \$$key = $value; $addtocart .= ",'\$$key'"; } } The problem is that it seems to be hanging at the while loop. Is there a cleaner way to write the foreach loop so that it will dump out the "submit" key? I've been trying different combinations, and am sure it is something simple I have boffed.I guess you want: if ($key != "submit") And you don't need to give names to submit buttons. Then it will not be posted and the condition is not necessary.