Jump to content

[SOLVED] Variable Variable name


Creech

Recommended Posts

first sry for my bad english  ::)

 

<input type="text" name="menge<?PHP echo $i ?>" value="<?php  echo $menge{$i}; ?>">

 

this code is in a loop

 

as you see i'm creating a name for that inputbox with a variable number creating with a loop 0 to x

 

so the name is menge0 menge1 menge2 and so on

as value i want $menge0 $menge1 ...

 

but i don't get it to work...

i just can't figure out how to creat a variable $menge with a variable number at the end...

like $variable$i

 

maybe someone can help me

 

ty

Creech

 

Link to comment
https://forums.phpfreaks.com/topic/38133-solved-variable-variable-name/
Share on other sites

first sry for my bad english  ::)

 

<input type="text" name="menge<?PHP echo $i ?>" value="<?php  echo $menge{$i}; ?>">

 

this code is in a loop

 

as you see i'm creating a name for that inputbox with a variable number creating with a loop 0 to x

 

so the name is menge0 menge1 menge2 and so on

as value i want $menge0 $menge1 ...

 

but i don't get it to work...

i just can't figure out how to creat a variable $menge with a variable number at the end...

like $variable$i

 

maybe someone can help me

 

thank you

Creech

 

 

instead of $menge{$i} use $menge.$i

 

instead of $menge{$i} use $menge.$i

that does not work i get nothing in return...

 

i try to use the other hint's but until now no  :o

 

<?

for ($i=0; $i<$number; $i++){

?>
<p>Menge: 
  <input type="text" name="menge<?PHP echo $i ?>" value="$menge0"> 

<?php } ?>

 

i just try again to explain ^^

the page is loaded... the name is created

now i want the name as a variable into the value part

so that after reloading the page that what was typed into the inputbox apears again...

 

anything else that could help to understand my problem?

 

ty

Creech

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.