Use a PHP variable as part of another variable name
20:42 29 May 2018

I have a variable called $repeater, which will either be low, moderate or high.

I also have variables called...

$low_protein_feed
$moderate_protein_feed
$high_protein_feed

I want to call one of these variables depending on what the value of $repeater is.

I got as far as this...

echo "${$repeater}_protein_feed";

...which outputs moderate_protein_feed, for example. But it echoes as text, when I want it to be echoing the value of $moderate_protein_feed variable.

I feel like I'm not far off. Thanks for any input

php variables