Is is possible to concatenate an object’s name?
The below doesn’t seem to work..
Trying to call $node->field_presenter_en;
$lang = 'en';
$node->field_presenter_.$lang;
${$node->field_presenter_.$lang};
Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Try:
This is called variable variables. More information here:
http://php.net/manual/en/language.variables.variable.php
Edit:
The user nickb has suggested a much more elegant solution below, and I will incorporate into this answer for easier reading (nickb: please let me know if you want me to remove this):