Jump to content

[SOLVED] foreach help


chard

Recommended Posts

Yeah thanks, I was just thinking I was being a bit to vague  :D

 

each $_POST turns into a variable say:

 

$_POST['test'] and $_POST['test1'] get submitted

then variable $test and $test1 are created

 

so that if $test and $test1 exist "something","something" can be assigned to them

Link to comment
Share on other sites

The code that sasa wrote is explicit -

 

For example with his code (unchanged) for $_POST vars  var1, var2 and var3

 

you would end up $var1 = "value1"  $var2 = "value2" $var3="value3"

 

So would use them as a normal var example

 

Echo $var1;
echo $var2;
echo $var3;

 

HTH

Dave

Link to comment
Share on other sites

Hello, yes i agree with php_dave, i think you are looking for something like following script..

<?php
$_POST['test'] = 'test';
$_POST['test1'] = 'test1'; 
foreach($_POST as $key => $value)
{
$$key = $value;
}
print_r($test);
print_r('<br>'.$test1);
?>

Regrds,

Link to comment
Share on other sites

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.