title: Call specific variable based on what another variable is set to.(PHP)
body: <p>I am not exactly sure how to word this in the form of a short question...the above called up many different answers that were not related, but I apologize if this has been asked before. </p>
  
  <p>I am trying to make a variable name itself based the value of another.</p>
  
  <p>I could simply create if statements for each one, but if I were able to declare the variable the way I want, it would save me about 20-30 lines of code, and make future additions much easier. </p>
  
  <p>Here is a better description. 
  This is the code that I am using at the moment. It is within a shortcode function for wordpress, to create a button based on user-given parameters. </p>
  
  <pre><code>extract(shortcode_atts(array(
        'size' =&gt; 'medium',
        'link' =&gt; '#',
        'text' =&gt; ''
      ), $atts));    
  $large_button_img = of_get_option('large_button_arrow_upload');
          $button_pos = of_get_option('button_image_position');
          if($button_pos == 'right' &amp;&amp; !empty($button_img)){
              $the_button = "&lt;a href='" . $link . "' class='" . $size . "_button custom_button" . $button_pos ."'&gt;" . $text . "&lt;img src='" . $large_button_img . "' id='button_img' alt='button image' /&gt;&lt;/a&gt;"; 
          }elseif($button_pos == 'left' &amp;&amp; !empty($button_img)){
              $the_button = "&lt;a href='" . $link . "' class='" . $size . "_button custom_button" . $button_pos ."'&gt;&lt;img src='" . $large_button_img . "' id='button_img' alt='button image' /&gt;" . $text . "&lt;/a&gt;"; 
          }else
          {
              $the_button = "&lt;a href='" . $link . "' class='" . $size . "_button custom_button'&gt;" . $text . "&lt;/a&gt;"; 
          }
          return $the_button;
  </code></pre>
  
  <p>In the above: 
  The function pulls the value of "size", "link" and "text" from the user given shortcode and generates a button. It sets the class based on the size...
  At the moment I have it to where the user can set different images for a large, medium and small button. </p>
  
  <p><strong>Question:</strong>
  IS IT POSSIBLE
  to return the name of the image source based on what size is set to. 
  soooo basically the equivalent of?</p>
  
  <pre><code>img src = '" . $($size)_button_img . "'
  </code></pre>
  
  <p>Where it places value of $size in the name of the variable that it pulls to tell it which image source to pull afterwards? (so the proper equivalent of the above would produce something like </p>
  
  <pre><code>img src= '" . $large_button_img ."'
  </code></pre>
  
  <p>or, if the user has medium selected</p>
  
  <pre><code>img src= '" . $medium_button_img . "'
  </code></pre>
  
  <p>If possible this save myself having to write if-statements for every possible option (basically copy the set of if-ifelse-else from above, everytime I have a new size setting available)...which eventually may become more of an efficiency issue. </p>
  
  <p>Thanks in advance for any help that can be given :)</p>
  
  <p><strong>ALSO</strong>
  Please ignore any syntax errors in the above set of code...I am working on this as you read this, so more than likely, if you see something wrong, it has already been fixed.</p>