Mombu the Php Forum

Go Back   Mombu the Php Forum > Php > Creating local vars from HTTP Post Array
User Name
Password
REGISTER NOW! Mark Forums Read




Reply
1 3rd July 16:33
codareef
External User
 
Posts: 1
Default Creating local vars from HTTP Post Array



working and needs editting.

Rather than manually changing each var -

$foo to $_POST['foo']

(there are simply too many) i'd like to do something like this -

while(list($key, $val) = each($_POST)) eval("\$.$key =
stripslashes($value)");

using a loop to create local variables for each variable in the HTTP Post
array.

I'm having trouble getting this to work.

Anyone help?

Cheers,

Javier

__________________________________________________ _______________
It's fast, it's easy and it's free. Get MSN Messenger today!
http://www.msn.co.uk/messenger
  Reply With Quote


 


2 3rd July 16:33
nick.jordan
External User
 
Posts: 1
Default Creating local vars from HTTP Post Array



Why not simply use Find and Replace in a text editor, if you only need to
change one form?

Nick
  Reply With Quote


 


3 3rd July 16:33
phpmail
External User
 
Posts: 1
Default Creating local vars from HTTP Post Array


foreach ($_POST as $key => $value) {
$$key = $value;
}

Something like that should work. But it's equivalent to turning RG on, so
why not just do that? Nothing's going to explode, it's just a language
feature.
  Reply With Quote
4 3rd July 16:34
pmorgan
External User
 
Posts: 1
Default Creating local vars from HTTP Post Array


try extract($_POST)

pete
  Reply With Quote
Reply


Thread Tools
Display Modes




666