title: Looping through variable references within a PHP function call
body: <p>I do not know if this is at all possible.</p>
  
  <p>I am fully aware that if <code>$stringname = 'Rating'</code>, then <code>$stringname()</code> will be the same as the function call <code>Rating()</code>.  I also know that if <code>$stringname = 'size'</code>, then <code>${$stringname}</code> will be the same as <code>$size</code>.  My thoughts hinge on these facts.</p>
  
  <p>What I'm trying to do is put in an XML function call for the PHP, to insert the results of a function into some text.</p>
  
  <p>Two examples of this XML function call are:</p>
  
  <pre><code>&lt;Function name="ListCensors"&gt;
      &lt;Arg name="pginf" /&gt;
      &lt;Arg value="/Lib:MainPage/child::*[self::Lib:Page or self::Lib:Series]/@rating" /&gt;
      &lt;Arg value="//Gen:Ratings/Gen:Rating[contains(|InsertList|,@code)]" /&gt;
  &lt;/Function&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>&lt;Function name="RatingImage"&gt;
      &lt;Arg value="Web_G" /&gt;
      &lt;Arg value="m" /&gt;
  &lt;/Function&gt;
  </code></pre>
  
  <p>You'll notice that these have a different number of arguments (<code>RatingImage()</code> has two, while <code>ListCensors()</code> has three), and that the first argument for the <code>ListCensors()</code> function call has the attribute name (pginf) instead of a value.  This is because while the attribute value passes a string, the attribute name refers to a variable name already defined in the PHP.
  So, here is the PHP, which currently does not work.</p>
  
  <pre><code>$func = $maintxt_child-&gt;getAttribute('name');
  $func_arg_els = $maintxt_child-&gt;getElementsByTagName('Arg');
  
  
  $func(for($func_arg_el_num = 0; $func_arg_el_num &lt; $func_arg_els-&gt;length; $func_arg_el_num++){
      if($fun_arg_els-&gt;item($func_arg_el_num)-&gt;hasAttribute('value')){
          $func_arg_els-&gt;item($func_arg_el_num)-&gt;getAttribute('value')
      } else {
          ${$func_arg_els-&gt;item($func_arg_el_num)-&gt;getAttribute('name')}
      }
  });
  </code></pre>
  
  <p>What I'm trying--and failing--to pull off is to set up something where the <code>&lt;Function&gt;</code> element can refer to ANY PHP function I've defined and loop through the Arg elements to send the proper information to these PHP functions.  How would be the right way of doing this?  If it is impossible, let me know, so I can figure out different ways of doing things.  Thanks.</p>