title: Regex to replace a special character in PHP?
body: <p>I have problem with a special character <code>§</code>. I want to replace multiple occurrences of <code>§</code> with single <code>§</code>. The following regex works fine on <a href="https://regex101.com/" rel="nofollow">Regex 101</a>. </p>
  
  <pre><code>$file_data = file_get_contents($file_name);
  $file_data = preg_replace('/\§+/g', '§',$file_data);
  </code></pre>
  
  <p>It changed</p>
  
  <blockquote>
    <p>§§§§§§§§§This free 3D robot game could redefine how kids learn to codeDigital Trends
    It’s hard to get kids to code. Up until very recently, it was largely ....</p>
  </blockquote>
  
  <p>to</p>
  
  <blockquote>
    <p>§This free 3D robot game could redefine how kids learn to codeDigital Trends
    It’s hard to get kids to code. Up until very recently, it was largely ....</p>
  </blockquote>
  
  <p>However, it is not working on the server after I upload it. Here is the <code>var_dump($file_data)</code> by PHP</p>
  
  <blockquote>
    <p>Â§Â§Â§Â§Â§Â§Â§Â§
    This free 3D robot game could redefine how kids learn to codeDigital Trends
    It’s hard to get kids to code. Up until very recently, it was largely ....</p>
  </blockquote>
  
  <p>So, there seems to be an additional character <code>Â</code> before every <code>§</code> in the <code>var_dump</code>. The extra character <code>Â</code> does not show up on webpage when echoed as HTML. It just shows up during plain PHP <code>var_dump</code>. How can I replace multiple occurrences of <code>§</code> using regex in PHP? </p>