title: Is this a bad pattern? (Switch inside for/foreach loop)
body: <p>I find myself writing code such as:</p>
  
  <pre><code>foreach($array as $key =&gt; $value) {
      switch($key) {
          case 'something':
              doSomething($value);
              break;
          case 'somethingelse':
              doSomethingElse($value);
              break;
      }
  }
  </code></pre>
  
  <p>Is there a better way to go about this?  Seems dirty to me, but I might just be over thinking it.    </p>
  
  <p>The only other alternative that I can think of is an if statement for each key, which doesn't seem any better.  I.e. :</p>
  
  <pre><code>if($array[0] == 'something') {
      doSomething($array[0]);
  }
  if($array[1] == 'somethingelse') {
      doSomethingElse($array[1]);
  }
  </code></pre>
  
  <p>(or something like that)  </p>
  
  <p>I can post exact code if needed, but this is the general outline of what happens.  Please critique away, but remember that I'm looking for help here.  So if I'm doing something egregiously wrong, then point it out.</p>