Reply to Re: Variable in a variable name

Your name:

Reply:


Posted by Garry Jones on 04/13/06 17:53

"Sjoerd" <sjoerder@gmail.com> skrev i meddelandet
news:1144926545.087071.20180@e56g2000cwe.googlegroups.com...

> It is possible in PHP to have variable variables (e.g. specify the name
> of the variable in another variable), but it is almost never what you
> want.

This seems to be the easiest way of doing it for me. To ease processing of
the form I want to use the same code. On the form there is a input named
"realname1". The following code sets the data entered into realname1 as
var1.

$x = 1;
$y = "var".$x;
$$y = $_POST['realname1'];

So far so good, that works.

But to be able to recycle this code I need to change the number 1 in
realname. How do I use the same "$x" in the followingbrackets.

$x = 1;
$y = "var".$x;
$$y = $_POST['realname' ($x)];

I then want to create a do while lopp. Something like..

DO WHILE $x <11
$y = "var".$x;
$$y = $_POST['realname' ($x)];

$x = $x + 1;
:Loop

I am greatful if you someone can explain the syntax for this.

Garry Jones
Sweden

[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

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