title: Get variable based on value of another variable
body: <p>Assume I have an object with 3 properties:</p>
  
  <pre><code>protected $validMainStatements;
  protected $validPrimaryStatements;
  protected $validSecondaryStatements;
  </code></pre>
  
  <p>And I got the following method:</p>
  
  <pre><code>public function selectType($stmt) {
      $stmtParts = MainServerInterface::parse($stmt);
      $type = $stmtParts[0] //returns either Main, Primary or Secondary
  }
  </code></pre>
  
  <p>Depending on the value of <code>type</code>, I want to use the associated property. A simple implementation would be:</p>
  
  <pre><code>public function selectType($stmt) {
      $stmtParts = MainServerInterface::parse($stmt);
      $type = $stmtParts[0] //returns either Main, Primary or Secondary
  
      if($type === "Main") {
          $usedProp = $this-&gt;validMainStatements;
      } elseif($type === "Primary") {
          $usedProp = $this-&gt;validPrimaryStatements;
      } elseif($type === "Secondary") {
          $usedProp = $this-&gt;validSecondaryStatements;
      }
  }
  </code></pre>
  
  <p>I think I don't have to mention that this is ugly and uncomfortable to use. Is there a way to implement this in an easier way? Something like (pseudocode):</p>
  
  <pre><code>$usedProp = $"valid".$type."Statements";
  </code></pre>