FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Variable Name With A Variable in it. Is It possible?





Dougie1
Well what I need is a script which will have a number in a variable. It is difficult to explain so I will give you what I have just now:

Code:

<?php
$count = 0;
$num = 1;
if (@$_POST['$num']) {
$url$count = @$_POST['1'];
$count++;
echo $url$count;
}
$num++;
if (@$_POST['$num']) {
$url$count = @$_POST['2'];
$count++;
echo $url$count;
}
?>

Now obviously line five will not function as it has two variables but hopefully you understand what I mean. I don't think there is any other option for what I am trying to do at the moment...

Please help. Thanks.
MrBlueSky
PHP supports variable variables: http://www.php.net/manual/en/language.variables.variable.php That's what you are looking for Smile
Dougie1
Wow. Thanks for the quick response *Starts singing Mr Blue Sky in celebration!*

Great song.

Thanks for the help and your link has a full stop at the end of it!!
MrBlueSky
Very Happy

Fixed the link.

If you run into problems using variable variables let me know.
Related topics
E-Cards with PHP & MySQL
MD5 Hashing
managing a bilingual site
JAva HELP
C++ pointers
error in my safe command
writing COM components in Perl
AJAX tutorial [2nd part now updated]
new guy needs help
Destiny versus freewill
Why Perl isn't easy to learn
Global Variable not working. Please test.
Do you have a right to be offended whenever you feel like it
What is wrong with this ????
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.