title: PHP: Dynamic Object Names
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/804850/get-php-class-property-by-string">Get PHP class property by string</a>  </p>
  </blockquote>
  
  
  
  <p>This is my original code:</p>
  
  <pre><code>function generateQuery($type, $language, $options)
  {
      // Base type
      $query = $this-&gt;Queryparts-&gt;print['filter'];
  
      // Language modifiers
      // Additional options
  
      return $query;
  }
  </code></pre>
  
  <p>The "print" is an array/hash defined as an object (with "(object)" casting). I wish to do something like this:</p>
  
  <pre><code>    $query = $this-&gt;Queryparts-&gt;$type['filter'];
  </code></pre>
  
  <p>To use the the $type variable  as the object name. Is this possible?</p>