title: preg_replace to replace all matches
body: <p>Hi I am creating a generator form to replace
  some CSS code I have ... it will find all the 
  class and id as well as dots, and place .class 
  in front of them ... </p>
  
  <p>now it's only replacing the first match 
  I have set the limit to -1 ... why it's ignoring it??</p>
  
  <p>html:</p>
  
  <pre><code>&lt;form action="get_html.php" method="post" id="form"&gt;
      html:&lt;textarea rows="50" cols="80" id="html_box" name="html" type="text" align="texttop"&gt;&lt;/textarea&gt;
      &lt;input id="button" type="submit" value="submit"&gt;&lt;/input&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>get_html.php </p>
  
  <pre><code>&lt;?php 
      $html= $_POST["html"]; 
      $string = (string)$html;
      $patterns = array();
      $patterns[0] = '/^[.]/';
      $patterns[1] = '/^[#]/';
      $patterns[2] = '/,/';
      $replacements = array();
      $replacements[0] = '.class .\1';
      $replacements[1] = '.class #\1';
      $replacements[2] = ', .class \1';
      $str= preg_replace($patterns,$replacements, $string, -1);
  ?&gt;
  &lt;textarea rows="50" cols="80"&gt;&lt;?php echo $str; ?&gt;&lt;/textarea&gt;
  </code></pre>