note 96980 added to reserved.variables.post

From: Date: Thu, 25 Mar 2010 18:37:27 +0000
Subject: note 96980 added to reserved.variables.post
Groups: php.notes 
Request: Send a blank email to php-notes+get-167415@lists.php.net to get a copy of this message
<?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; } ?> ---- Server IP: 69.147.83.197 Probable Submitter: 24.21.2.111 ---- Manual Page -- http://www.php.net/manual/en/reserved.variables.post.php Edit -- https://master.php.net/note/edit/96980 Del: integrated -- https://master.php.net/note/delete/96980/integrated Del: useless -- https://master.php.net/note/delete/96980/useless Del: bad code -- https://master.php.net/note/delete/96980/bad+code Del: spam -- https://master.php.net/note/delete/96980/spam Del: non-english -- https://master.php.net/note/delete/96980/non-english Del: in docs -- https://master.php.net/note/delete/96980/in+docs Del: other reasons-- https://master.php.net/note/delete/96980 Reject -- https://master.php.net/note/reject/96980 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#167415) next »