vourexx Posted April 11, 2013 Share Posted April 11, 2013 Hello i need a way to do this: i have a mysql query to load the results with mysql_fetch_object, so i have in database two fields like title_english and title_german via php i setup the language with this $lang = german; so i want to do the folowing: echo $result->title_.$lang; to load every time in given language, for example i need this variable $result_ to run as $result->title_german for load my results but this not working any idea ? Quote Link to comment https://forums.phpfreaks.com/topic/276842-how-to-use-a-string-as-custom-variable/ Share on other sites More sharing options...
trq Posted April 11, 2013 Share Posted April 11, 2013 This is where using arrays comes in handy: $result['title_' . $lang]; What your trying to do is called variable variables and is far less efficient / easy to follow. Quote Link to comment https://forums.phpfreaks.com/topic/276842-how-to-use-a-string-as-custom-variable/#findComment-1424237 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.