title: Comparing in_array values
body: <p>I have a array of val which has dynamic strings with underscores. Plus I have a variable $key which contains an integer. I need to match $key with each $val (values before underscore).</p>
  
  <p>I did the following way:</p>
  
  <pre><code>&lt;?php
      $key = 2; //always a dynamic number
  $val = array('3_33', '2_55'); //always a dynamic string with underscore
  if(in_array($key, $val)) {
      echo 'Yes'; 
  } 
  else
  {
      echo 'No';  
  }
  ?&gt;
  </code></pre>
  
  <p>Though this code works fine, I want to know if its a correct way or suggest some better alternative.</p>