title: placing single quote around each words
body: <p>I have list of words separated by a newline, for example:</p>
  
  <pre><code>apple
  ball
  cat
  dog
  </code></pre>
  
  <p>I wanted to separate each of the words by a comma and then place single quotes around each word.</p>
  
  <p>I could remove the newline character and place a comma, but I couldn't enclose each word with single quotes. </p>
  
  <p>I want the final result to look like this:</p>
  
  <p>'apple','ball','cat','dog' and so on.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>$words = getlist();
  
  $str = preg_replace('#\s+#',',',trim($words));
  echo $str;
  
  function getlist($list)
  {
      //words list
  }
  </code></pre>