You are here: Re: Simple Variable Syntax Question. « PHP Programming Language « IT news, forums, messages
Re: Simple Variable Syntax Question.

Posted by denis on 01/11/07 22:23

There is a shorter way I think. If we assume those are POST variables, the
code might look something like

foreach ($_POST as $name => $value)
$name = $value;

"ZeldorBlat" <zeldorblat@gmail.com> wrote in message
news:1168533804.991748.11600@i56g2000hsf.googlegroups.com...
>
> blackberryoctopus wrote:
>> I am receiving 40 variables from an external source into my php script.
>> I need to have for loop cycle through those and assign them to
>> variables in the php script. I am unsure of the syntax, but it would be
>> something like the following
>>
>> for($i=0;$i<40;$i++){
>> $phpvar+$i = receivedData+$i
>> }
>>
>>
>> The data coming in is named as follows data1, data2, data3, ... data40.
>> So I need the php variables to be named in the same way. Whats the
>> syntax here? Thanks for any help.
>
> Data coming in from where? GET? POST? Command line? Cookies? Let's
> suppose it's POST and you have POST variables named data1, data2, ...
> data40. Then it would be something like this:
>
> for($i = 1; $i <= 40; $i++) {
> $name = "data$i";
> $$name = $_POST[$name];
> }
>

 

Navigation:

[Reply to this 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

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