title: PHP str_replace slash and quote
body: <p>I had my data called from db with words contained <code>'</code> such as <code>company's</code> and some words display like <code>company\\\\\'s</code>, despite I had a function to replaced all those special characters into normal, but wording  like <code>company\'s</code> is still around. Is there any proper way to replace all kind of special characters properly? </p>
  
  <pre><code>function chrEncode($data) {
      $data = str_replace('â€™', '&amp;#39;' ,$data);
      $data = str_replace('Ã©', 'é' ,$data);
      $data = str_replace('â€', '-' ,$data);
      $data = str_replace('-œ', '&amp;#34;' ,$data);
      $data = str_replace('â€œ', '&amp;#34;' ,$data);
      $data = str_replace('Ãª', 'ê' ,$data);
      $data = str_replace('Ã¶', 'ö' ,$data);
      $data = str_replace('â€¦', '...' ,$data);
      $data = str_replace('-¦', '...' ,$data);
      $data = str_replace('â€“', '–' ,$data);
      $data = str_replace('â€²s', '’' ,$data);
      $data = str_replace('-²s', '’' ,$data);
      $data = str_replace('â€˜', '&amp;#39;' ,$data);
      $data = str_replace('-˜', '&amp;#39;' ,$data);
      $data = str_replace('-“', '-' ,$data);
      $data = str_replace('Ã¨', 'è' ,$data);
      $data = str_replace('ï¼ˆ', '(' ,$data);
      $data = str_replace('ï¼‰', ')' ,$data);
      $data = str_replace('â€¢', '&amp;bull;' ,$data);
      $data = str_replace('-¢', '&amp;bull;' ,$data);
      $data = str_replace('Â§ï‚§', '&amp;bull;' ,$data);
      $data = str_replace('Â®', '&amp;reg;' ,$data);
      $data = str_replace('â„¢', '&amp;trade;' ,$data);
      $data = str_replace('Ã±', 'ñ' ,$data);
      $data = str_replace('Å‘s', 'ő' ,$data);
      $data = str_replace('\\\"', '&amp;quot;' ,$data);
      $data = str_replace("\r", '&lt;br&gt;' ,$data);
      $data = str_replace("\\r", '&lt;br&gt;' ,$data);
      $data = str_replace("\n", '&lt;br&gt;' ,$data);
      $data = str_replace("\\n", '&lt;br&gt;' ,$data);
      $data = str_replace("\\\'", '&amp;#39' ,$data);
      $data = str_replace("'", "&amp;#39" ,$data);
  
      return $data;
  }
  </code></pre>
  
  <p>Please advise, thanks!</p>