Variable Question

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Variable Question

Post by spacebiscuit »

Hi,

I am processing the input from a web form:

Variables are named as follows:

data1
data2
data3

I am using a loop to process the data.

$_POST[data.$y]

I don't think this is quite right though - how do I use the value of a variable in a variable name.

Thanks,
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Variable Question

Post by social_experiment »

Code: Select all

<?php
 $_POST['data' . $y];
?>
Place the non-variable part in single or double quotes
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
spacebiscuit
Forum Contributor
Posts: 390
Joined: Mon Mar 07, 2005 3:20 pm

Re: Variable Question

Post by spacebiscuit »

Thanks
Post Reply