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
https://forums.phpfreaks.com/topic/71017-solved-foreach-help/#findComment-357082
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
https://forums.phpfreaks.com/topic/71017-solved-foreach-help/#findComment-357125
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
https://forums.phpfreaks.com/topic/71017-solved-foreach-help/#findComment-357129
Share on other sites

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.