title: Exploding empty string to array in PHP
body: <p>I am trying to find why I am getting the <code>comma</code> when trying to add <code>$item</code> to the <code>$str</code> while it is empty. The result is like</p>
  <blockquote>
  <p>,mu-16</p>
  </blockquote>
  <p>but it is fine while for example I have <code> $str =&quot;mu-16,m-13&quot;;</code> as expected. How can I fix this to not add comma to the <code>$newstr</code> when the <code>$str</code> is empty</p>
  <pre><code>// $str =&quot;mu-16,m-13&quot;;
  $str =&quot;&quot;;
  $arr = explode(',', $str);
  $item = &quot;mu-16&quot;;
   if (($key = array_search($item, $arr)) !== false) {
       echo &quot;Item is already in list&quot;;
   }
   else{
      array_push( $arr,$item);
      $newstr = implode (&quot;,&quot;, $arr);
      echo $newstr;
  }
  </code></pre>