Check if value exists in comma separated string with PHP
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/2322505/comma-separated-string-to-array">comma-separated string to array</a>  </p>
</blockquote>



<p>I need to check if my id exists in comma separated string.</p>

<p>My string is saved as <code>"1,2,3,4,10"</code> in database.</p>

<p>I have tried </p>

<pre><code>$HiddenProducts = array($sqlvalue);

if (in_array(2, $HiddenProducts)) {
  echo "Available";
} else {
  echo "Not available";
}
</code></pre>

<p>It is not working. Any solutions please...</p>
