mister_t101 Posted March 25, 2006 Share Posted March 25, 2006 is there a way to create a variable with the name of a value of another variable? for example $foo=1;dynamically create a variable named $1$foo+=1;dynamically create a variable named $2 Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted March 25, 2006 Share Posted March 25, 2006 You probably want to look at [a href=\"http://us3.php.net/manual/en/language.variables.variable.php\" target=\"_blank\"]variable variables.[/a][code]<?php$one = 'two';$$one = 'three'; // this is equivalent to $two = 'three';echo '$one = ' . $one . '<br>';echo '$$one = ' . $$one . '<br>';echo '$two = ' . $two . '<br>';?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted March 25, 2006 Share Posted March 25, 2006 variables that start with a number are invalid so you might want to name your variables like so:$_1;$_2;etc.As they are valid Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.