title: php switch case statement to handle ranges
body: <p>I'm parsing some text and calculating the weight based on some rules. All the characters have the same weight. This would make the switch statement really long can I use ranges in the case statement.</p>
  
  <p>I saw one of the answers advocating associative arrays.</p>
  
  <pre><code>$weights = array(
  [a-z][A-Z] =&gt; 10,
  [0-9] =&gt; 100,
  ['+','-','/','*'] =&gt; 250
  );
  //there are more rules which have been left out for the sake of clarity and brevity
  $total_weight = 0;
  foreach ($text as $character)
  {
    $total_weight += $weight[$character];
  }
  echo $weight;
  </code></pre>
  
  <p>What is the best way to achieve something like this?
  Is there something similar to the bash case statement in php?
  Surely writing down each individual character in either the associative array or the switch statement can't be the most elegant solution or is it the only alternative?</p>