morocco-iceberg Posted June 6, 2010 Share Posted June 6, 2010 Is it possible to create a variable name using variable variables and an extension? i.e $$table with _0 after so if $table = apple the new variable name would be $apple_0. If this isn't possible could you tell me a way around it? Quote Link to comment https://forums.phpfreaks.com/topic/204004-variable-variables-with-name-extensions/ Share on other sites More sharing options...
ignace Posted June 6, 2010 Share Posted June 6, 2010 Why bother asking, try it and you'll see for yourself if it works. And for the record, yes it works. Quote Link to comment https://forums.phpfreaks.com/topic/204004-variable-variables-with-name-extensions/#findComment-1068490 Share on other sites More sharing options...
morocco-iceberg Posted June 6, 2010 Author Share Posted June 6, 2010 I ask because I have tried it and it doesn't work, so I assumed I was doing it wrong. Quote Link to comment https://forums.phpfreaks.com/topic/204004-variable-variables-with-name-extensions/#findComment-1068492 Share on other sites More sharing options...
Mchl Posted June 6, 2010 Share Posted June 6, 2010 $table = 'apple'; ${$table.'_0'} = 'something'; echo $apple_0; Quote Link to comment https://forums.phpfreaks.com/topic/204004-variable-variables-with-name-extensions/#findComment-1068493 Share on other sites More sharing options...
morocco-iceberg Posted June 6, 2010 Author Share Posted June 6, 2010 Awesome, works perfectly. Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/204004-variable-variables-with-name-extensions/#findComment-1068494 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.