Jump to content

$_POST[]; i want $_POST[$id]; like this


blazing_bruce

Recommended Posts

[!--quoteo(post=358328:date=Mar 25 2006, 06:45 PM:name=blazing_bruce)--][div class=\'quotetop\']QUOTE(blazing_bruce @ Mar 25 2006, 06:45 PM) [snapback]358328[/snapback][/div][div class=\'quotemain\'][!--quotec--]
hello,
now we are using $_POST['id']; like this .
i want to use $_POST['$id']; help me.

i want to place a php variable inside of $_POST[] please help me.

Thank you,
Karthi keyan.
[/quote]

I tried with sessions varables and even a class sorry.



[!--quoteo(post=358338:date=Mar 25 2006, 07:06 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 25 2006, 07:06 PM) [snapback]358338[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I tried with sessions varables and even a class sorry.
[/quote]


this is a long shot but not tested theo can try theo

[code]

$_POST['id'] = '$id';

[/code]


dont even know if this is possable but can try lol
[!--quoteo(post=358338:date=Mar 25 2006, 02:15 PM:name=redarrow)--][div class=\'quotetop\']QUOTE(redarrow @ Mar 25 2006, 02:15 PM) [snapback]358338[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I tried with sessions varables and even a class sorry.
this is a long shot but not tested theo can try theo

[code]

$_POST['id'] = '$id';

[/code]
dont even know if this is possable but can try lol
[/quote]


I would have thought it would be like placing any other variable into it?
[code]$_POST[$filName];[/code]
[!--quoteo(post=358351:date=Mar 25 2006, 07:54 PM:name=ShadowOfSilence)--][div class=\'quotetop\']QUOTE(ShadowOfSilence @ Mar 25 2006, 07:54 PM) [snapback]358351[/snapback][/div][div class=\'quotemain\'][!--quotec--]
I would have thought it would be like placing any other variable into it?
[code]$_POST[$filName];[/code]
[/quote]

it is

[code]
$foo['bar'] = 'test';

$a_key = 'bar';

echo $foo[$a_key];
[/code]
Rather than using the single quotes for the index/key you use double quotes, that way PHP will use the value stored in the id variable as the index/key. As currently PHP was treating your variable 'as-is' and so was tring to find a index/key called $id in the _POST array.

So eother of the following will work
[code]$_POST["$id"];
// OR
$_POST[$id];[/code]

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.