title: Implementing a simple lookup table with PHP
body: <p>I often find myself needing a simple PHP lookup table where I don't want to bother using a database.</p>
  
  <p>For instance, I might have:</p>
  
  <pre><code>1 stands for "Good"
  2 stands for "Bad"
  3 stands for "Ugly"
  </code></pre>
  
  <p>Two ways it could be implemented are shown below.  Is one more efficient than the other?  Is there any other more intuitive ways to implement this?</p>
  
  <pre><code>switch($code)
  {
      case 1:$result="Good";break;
      case 2:$result="Bad";break;
      case 3:$result="Ugly";break;
      default:$result=NULL;
  }
  
  $array=array(1=&gt;"Good",2=&gt;"Bad",3=&gt;"Ugly");
  $result=$array[$code];
  </code></pre>