-1

This is the first time I've come across this issue. How can I get a variable where the variable determines the variable to get.

$foobar_list = '123123';
$type = 'foobar'
echo {$type}_list; 
Alex
  • 9,215
  • 8
  • 39
  • 82
  • Don't understand the downvote. It is impossible to search for something you don't know the name of. – Alex Mar 16 '17 at 06:37

1 Answers1

2

Please refer to Dynamic variable names in PHP

As stated there, you need to access it as echo ${$type . '_list'}

Edit: fixed a typo

Community
  • 1
  • 1
Dhruva Sagar
  • 7,089
  • 1
  • 25
  • 34