title: php foreach loop use variable in function name
body: <p>I have a foreach loop that creates a function for each array item. I need a unique name for each function created and would like to include the current array item in the function name but don't know how to do this.</p>
  
  <p>At the moment I have the function named as "function ttm_global__shortcode()" however I would like it to be "function ttm_global_$acf_field_shortcode()"</p>
  
  <pre><code>$acf_fields = array("telephone_number", "fax_number", "email_address", "skype");
  
  foreach($acf_fields as $acf_field) {    
      function ttm_global__shortcode() {
          ob_start();
          echo get_field($acf_field, 'options');
          $output = ob_get_contents();
          ob_end_clean();
          return $output; 
      }
      add_shortcode($acf_field, 'ttm_global_'.$acf_field.'_shortcode');
  }
  </code></pre>
  
  <p>Thanks</p>