title: Using foreach to loop through variable names
body: <p>I have a for else loops with 5 sections in and in each one I have the same code just with different variable names:</p>
  
  <p>example:</p>
  
  <pre><code>if($name=="bob"){
      // do things with $name1
  }
  elseif($name=="bob2"){
      // do things with $name2
  }
  // ...
  </code></pre>
  
  <p>if there a way for me to just do a loop where I can have an array of variable names ie $namearray = "$name1","$name2" ..</p>
  
  <p>and then the loop can just replace the variable names on each iteration?</p>