dodgeitorelse Posted July 4, 2011 Share Posted July 4, 2011 Hi everyone, I have several variables named $list1 through $list20. I need to know if it is possible to use another variable to fill in the number at the end of the first variable depending on a server that is selected. The variable to determine the server is $server['o']['id'] The id is a number from 1 - 20 I tried $list{$server['o']['id']} but all I get for a value is the number and not the $list before it. Due to the existing code that I am trying to use this in I have to be able to do this inside single quotes as double quotes kills all the code (shows nothing but a blank page for everything) How can this be achieved? Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/ Share on other sites More sharing options...
priti Posted July 4, 2011 Share Posted July 4, 2011 Try $list.$server['o']['id']; Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/#findComment-1238219 Share on other sites More sharing options...
dodgeitorelse Posted July 4, 2011 Author Share Posted July 4, 2011 Try $list.$server['o']['id']; still only get a value of the number and not the $list before it. Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/#findComment-1238228 Share on other sites More sharing options...
cyberRobot Posted July 4, 2011 Share Posted July 4, 2011 To dynamically generate variable names, the curly quotes need to go around the entire variable name: ${'list' . $server['o']['id']} Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/#findComment-1238235 Share on other sites More sharing options...
dodgeitorelse Posted July 4, 2011 Author Share Posted July 4, 2011 To dynamically generate variable names, the curly quotes need to go around the entire variable name: ${'list' . $server['o']['id']} Thank you very much . I had tried the curly quotes but put first one before the dollar sing instead of after. Again thank you for your working solution. Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/#findComment-1238242 Share on other sites More sharing options...
QuickOldCar Posted July 4, 2011 Share Posted July 4, 2011 I've heard curly braces called curly brackets – flower brackets - squiggly brackets - curvy brackets - curvy braces , and yes even more. The first 3 are commonly used depending what country you live in. But in no way is { or } a quote. Quote Link to comment https://forums.phpfreaks.com/topic/241062-php-variables-combined/#findComment-1238252 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.