Re: [PHP] $_POST into a formatted string, help!

2002-07-03 Thread 1LT John W. Holmes

- Original Message -
From: "Erik Price" <[EMAIL PROTECTED]>
> > 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...


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] $_POST into a formatted string, help!

2002-07-03 Thread Erik Price



> Oh man I hope you don't shoot yourself when you realize how easy this 
> is..
>
> foreach ($_POST as $key => $val)
> {
> $str .= "&$key=$val";
> }
>
> Then just crop the first char off and there you go.

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);




Erik









Erik Price
Web Developer Temp
Media Lab, H.H. Brown
[EMAIL PROTECTED]


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] $_POST into a formatted string, help!

2002-07-03 Thread Scott Fletcher

Hey, that is new to me!  Thanks!  FletchSOD

"Kevin Stone" <[EMAIL PROTECTED]> wrote in message
01de01c22216$984c5740$6501a8c0@kevin">news:01de01c22216$984c5740$6501a8c0@kevin...
> Oh man I hope you don't shoot yourself when you realize how easy this is..
>
> foreach ($_POST as $key => $val)
> {
> $str .= "&$key=$val";
> }
>
> Then just crop the first char off and there you go.
>
> -Kevin
>
> - Original Message -
> From: <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Tuesday, July 02, 2002 4:10 PM
> Subject: [PHP] $_POST into a formatted string, help!
>
>
> > Hello,
> >
> > I need to get _$POST into a string in this form:
> > tree=green&sky=blue&sun=yellow , how can i accomplish this?
> >
> > THanks.
> >
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] $_POST into a formatted string, help!

2002-07-02 Thread Analysis & Solutions

On Tue, Jul 02, 2002 at 04:19:50PM -0600, Kevin Stone wrote:
> Oh man I hope you don't shoot yourself when you realize how easy this is..
> 
> foreach ($_POST as $key => $val)
> {
> $str .= "&$key=$val";
> }

But, don't forget the post may contain spaces or other characters which
will trip up a URI, so it'd be a good idea to urlencode the $val;

  $str .= "&$key=" urlencode($val);

--Dan

-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] $_POST into a formatted string, help!

2002-07-02 Thread Kevin Stone

Oh man I hope you don't shoot yourself when you realize how easy this is..

foreach ($_POST as $key => $val)
{
$str .= "&$key=$val";
}

Then just crop the first char off and there you go.

-Kevin

- Original Message - 
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, July 02, 2002 4:10 PM
Subject: [PHP] $_POST into a formatted string, help!


> Hello,
> 
> I need to get _$POST into a string in this form: 
> tree=green&sky=blue&sun=yellow , how can i accomplish this?
> 
> THanks.
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] $_POST into a formatted string, help!

2002-07-02 Thread php

Hello,

I need to get _$POST into a string in this form: 
tree=green&sky=blue&sun=yellow , how can i accomplish this?

THanks.


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php