Page 1 of 1

Return the $_GET array as a string?

Posted: Sat Jan 10, 2004 11:09 pm
by LonelyProgrammer
Is there any way to convert the $_GET array back into its original query string?

Posted: Sat Jan 10, 2004 11:56 pm
by Nay
Maybe:

Code: Select all

echo $_SERVER['QUERY_STRING'];
is what you're looking for.

-Nay

Posted: Sun Jan 11, 2004 1:10 am
by LonelyProgrammer
*smack forehead for forgetting to check documentation*

But what if I want the string passed using the $_POST method?

Posted: Sun Jan 11, 2004 1:40 am
by Nay

Code: Select all

<?php

$string = '';

foreach($_POST as $key => $value) {
   if(empty($string)) {
      $string .= $key . "=" . $value;
   } else {
      $string .= "&" . $key . "=" . $value
   }
}

?>
I'm not sure if there's any other way though.

-Nay