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? 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. 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. 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; 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 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
Archived
This topic is now archived and is closed to further replies.