Variable for the field name of mysql row result
- by ana
I'm retrieving a row with php from mysql and it has fields like: name_en, name_es, name_de...
I want to retrieve the right field base on my $lang variable (en, es, de...). If the $lang variable is 'es', I'd need to get $row['name_es'].
I've tried this (based on this thread), but it's not working:
$name = $row->{'name_'.$lang};
Any idea how can I use a variable as the name of the field of a row?
Thanks in advance for your help!