title: How to use Variable variables in Smarty?
body: <p>I want to use variable variables in smarty. I know that we can use it in <a href="http://php.net/manual/en/language.variables.variable.php" rel="nofollow noreferrer">PHP</a>. But I am unable to find any way to achieve the same in Smarty template file. Consider the below scenario.</p>
  
  <p>I have multiple variables which I pass from PHP file to Smarty tpl file. All these variables name have some similar pattern. e.g. <code>$test_1</code>, <code>$test_2</code>, <code>$test_3</code> and so on.</p>
  
  <p>This is how, actually I am trying to achieve it. Here, <code>$COUNTER</code> represents 1, 2, 3....</p>
  
  <pre><code> {$SELECTED_VALUE = "test_{$COUNTER}"}
   {$$SELECTED_VALUE|@print_r}
  </code></pre>
  
  <p>But when I try to print it out, it gives me error</p>
  
  <pre><code>Syntax Error in template "test.tpl" on line 127 "{$$SELECTED_VALUE|@print_r}" - Unexpected "$", expected one of: "{" , "identifier"
  </code></pre>
  
  <p>Now, in PHP, I can get the values of these variables using double <code>$$</code> symbols. But I am unable to find any way to achieve the same in a smarty tpl file. </p>
  
  <p>I have gone through these links, but couldn't understand anything out of it.</p>
  
  <p><a href="https://stackoverflow.com/questions/19962650/variable-variable-in-smarty-templates">Variable Variable in Smarty Templates</a></p>
  
  <p><a href="https://stackoverflow.com/questions/23933787/dynamics-variables-in-smarty-in-loop">Dynamics variables in smarty in loop</a></p>
  
  <p>Kindly guide me here, if it is possible.</p>