title: How to remove duplicate from string and then produce a comma separated values with single quotes in php
body: <p>How i can remove duplicate from this string and then produce a comma separated values with single quotes to later use IN('1','2') query.</p>
  
  <pre><code>$str=1,1,2,2,2,;
  </code></pre>
  
  <p>And i want this</p>
  
  <pre><code>$str ='1','2';
  </code></pre>
  
  <p>This is what i have tried so far.</p>
  
  <pre><code>$string = rtrim($str,',');
  $result = implode(",", array_unique(explode(',', $string)));
  echo'&lt;pre&gt;';print_r($result);
  </code></pre>
  
  <p>produced result:</p>
  
  <pre><code>1,2
  </code></pre>