Reply to Re: Perform the same action(s) on a variable number of POST variables

Your name:

Reply:


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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация