|
Posted by Gleep on 06/15/07 03:38
On Thu, 14 Jun 2007 23:42:36 +0200, Michael Fesser <netizen@gmx.de> wrote:
>.oO(joboils@hotmail.com)
>
>>Hope some of the gurus around here can help me stop feeling stupid.
>>Is there some way to have the same actions (like, say, STR_REPLACE(),
>>TRIM() or STRTOUPPER(), and stuff like that) operate on all the
>>variables passed by POST from a range of web forms without writing
>>these actions specifically for each form's variables?
>
>foreach?
>
>Micha
yup, treat $_POST as you would an array because it is an array
example
foreach($_POST as $key => $item)
{
$$key = trim($_POST[$key]);
}
key is a variable variable
it would be the equivalent of this
$apple = $_POST['apple'];
$orange = $_POST['orange'];
$pear = $_POST['pear'];
etc..
with the loop above you don't have to go thru the process of calling each one out
it's done throu the loop - hope that makes sense
[Back to original message]
|