Jump to content

Recommended Posts

Hey everyone,

      I'm working on some form submission/validation code and I was wondering if there was anywa that using the code below I could set the variable names as well?

 

Right now im just displaying the data;

	foreach ($_POST as $key => $value) {
    echo $key . ":";
    echo $value . "<br/>";
  }

 

Displays like this, properly;

ShipCuFName:nick

ShipCuLName:girard

ShipCuAddr:12 autumn ave

 

but i'd like to be able to assign the actual field name $key(ShipCuFName) is referring to as a variable with the $value (nick)in it without having to individually code it?

thank you in advance!

NickG

Will create the variable name with the value of $key and assign it to the value of $value.  Notice the double '$', make sense?

 

$$key = $value;

 

So if you do this after the loop:

 

echo $ShipCuFName;

 

It will output "nick".

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.