title: How to check if a value exists in a array using PHP
body: <p>I am trying to check if a user input value exists in a array list using PHP. Here is my code:</p>
  
  <pre><code>$chkvalue=$_POST['id'];
  
  $sql=$dbh-&gt;prepare("my query hear");
  $sql-&gt;execute();
  $memers=$sql-&gt;fetch(PDO::FETCH_BOTH);
  </code></pre>
  
  <p>I got my list of values in array <code>$memers</code>. When I use <code>var_dump($memers);</code> I can see all the values in the array. Now, I want to check weather <code>$chkvalue</code> exists in the array <code>$memers</code>.</p>
  
  <p>I tried the code below: </p>
  
  <pre><code>if (in_array($chkvalue ,$memers)) {
     echo "Value exists";
    } else {
      echo "Value doesn't exists";
      }
  </code></pre>
  
  <p>But, it is always showing <code>Value doesn't exists</code>.</p>
  
  <p>For example: my array contains {23568,456982,123489,125895,154879,124648}</p>
  
  <p>Now I want to check if 456982 exists in that array or not.</p>
  
  <p>i tried FETCH_NUM</p>
  
  <p>i got below result</p>
  
  <pre><code>array(5) { [0]=&gt; string(6) "600258" [1]=&gt; string(15) "A SURYANARAYANA" [2]=&gt; string(6) "420575" [3]=&gt; string(1) "A" [4]=&gt; string(10) "2016-07-05" } 
  
  array(5) { [0]=&gt; string(6) "223511" [1]=&gt; string(20) "A UMA MAHESWARA RAO" [2]=&gt; string(6) "600258" [3]=&gt; string(1) "A" [4]=&gt; string(10) "2016-07-05" }
  
   array(5) { [0]=&gt; string(6) "907774" [1]=&gt; string(19) "A UMA MAHESWARA RAO" [2]=&gt; string(6) "223511" [3]=&gt; string(1) "A" [4]=&gt; string(10) "2016-07-05" } 
  
  array(5) { [0]=&gt; string(6) "688108" [1]=&gt; string(13) "M BALA BALAJI" [2]=&gt; string(6) "907774" [3]=&gt; string(1) "A" [4]=&gt; string(10) "2016-07-05" } 
  </code></pre>