Re: $_POST into a formatted string, help!
| From: | 1LT John W. Holmes | Date: | Wed, 03 Jul 2002 14:41:58 +0000 |
| Subject: | Re: $_POST into a formatted string, help! | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-105199@lists.php.net to get a copy of this message | ||
----- Original Message -----
From: "Erik Price" <pricee@hhbrown.com>
> > foreach ($_POST as $key => $val)
> > {
> > $str .= "&$key=$val";
> > }
Make sure you define $str = ""; before it enters the loop, othewise you'll
throw some warnings if your error reporting level is set high. It's because
$str is undefined on the first loop, yet your adding something to it.
> Even easier, though maybe requiring a tiny bit extra memory to deal with
> the array:
>
> $arr = array();
> foreach ($_POST as $key => $val) {
> $arr[] = $key . '=' . $val;
> }
> $str = implode('&', $arr);
Hmmm...doesn't look easier, but whatever works! :)
---John Holmes...