note 29998 modified in language.variables.variable by philip

From: Date: Wed, 16 Mar 2005 01:04:10 +0000
Subject: note 29998 modified in language.variables.variable by philip
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-86507@lists.php.net to get a copy of this message
Here is a very simple way of getting items from the $_POST superglobal into seperate variables. I did this so I can easily print information in a form without having to worry about "this value isn't set" messages. will create variables in the form $frm_nameInForm. foreach($_POST as $key => $value) { $varname = "frm_".$key; $$varname = $value; } [Editor Note: Instead of this code, you could simply use extract() or import_request_variables() -Philip] --was-- Here is a very simple way of getting items from the $_POST superglobal into seperate variables. I did this so I can easily print information in a form without having to worry about "this value isn't set" messages. will create variables in the form $frm_nameInForm. foreach($_POST as $key => $value) { $varname = "frm_".$key; $$varname = $value; } This uses foreach, so you need at least PHP 4 to do this. Although you can easily do it with a more compatible while loop as well. http://php.net/manual/en/language.variables.variable.php

« previous php.notes (#86507) next »