note 96980 deleted from reserved.variables.post by danbrown

From: Date: Thu, 25 Mar 2010 18:49:14 +0000
Subject: note 96980 deleted from reserved.variables.post by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-167416@lists.php.net to get a copy of this message
Note Submitter: admin at jbud dot org ---- <?php function post2get() { $array = $_POST; $format = "?"; foreach( $array as $key => $value ) { if ($i == 1) { $format .= "$key=$value"; } else { $format .= "&$key=$value"; } $i++; } return $format; } ?> formats _POST array into a get string compatible with a URL Example: "?render=Forums&forum=1&thread=1" will be returned from: <?php print_r($_POST); /*OUTPUT: Array ( [render] => Forums [forum] => 1 [thread] => 1 ) */ ?> Alternatively, you can use a function like this to pass from _GET to _GET, so you can parse a url into the next url easily: <?php function get() { $array = $_GET; $format = "?"; foreach( $array as $key => $value ) { if ($i == 1) { $format .= "$key=$value"; } else { $format .= "&$key=$value"; } $i++; } return $format; } ?>

« previous php.notes (#167416) next »