Undefined variable error with 'variable variables'

I intend to output something like ‘$email->prospect->totalHits’. For some reason, I need to store the name of this variable into another variable first. So, I write $value = ‘email->prospect->totalHits’ in my controller and pass $value to the view. But, when I try to output using,


echo $$value;

I get the error ‘Undefined variable: email->prospect->totalHits’. Not sure what is wrong here.

Also, the $$value is being echoed inside a foreach loop which says ‘foreach($array as $email){}’. So, ‘$email’ comes from there.