Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

$$ variable variables not working with foreach loop

Status
Not open for further replies.

Spork52

Programmer
Nov 20, 2007
134
US
I'm trying to loop through an array of variable names to grab values from a form and assign the values to variables. It's not working--none of the form values get picked up. Here's what I've tried:

Code:
$field_list = array("field1","field2",etc.)

foreach ($field_list as $value) 
{
$$value = $_POST[$value];
echo "<br>".$value.": ".$$value;
}

The echo statement outputs:

field1:
field2:
etc.

Okay, so what stupid mistake am I making?
 
Oops. Please ignore. Nothing wrong with code. Something else. How can I delete this post?
 
Hi

Spork52 said:
How can I delete this post?
Click the
[navy]Inappropriate post?[/navy]
[navy]If so, Red Flag it![/navy]
at the bottom of your post, then in the popup window type a short explanation for the forum management about what you are asking for and why.

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top