I have problem with a special character §. I want to replace multiple occurrences of § with single §. The following regex works fine on Regex 101.
$file_data = file_get_contents($file_name);
$file_data = preg_replace('/\§+/g', '§',$file_data);
It changed
§§§§§§§§§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 ....
to
§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 ....
However, it is not working on the server after I upload it. Here is the var_dump($file_data) by PHP
§§§§§§§§ 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 ....
So, there seems to be an additional character  before every § in the var_dump. The extra character  does not show up on webpage when echoed as HTML. It just shows up during plain PHP var_dump. How can I replace multiple occurrences of § using regex in PHP?
gmodifier since it doesn't exist in php regex. My first guess would be to try theumodifier:/§+/u. Have funheader('Content-Type: text/html; charset=utf-8');.datfile with HTML content.uwas correct. If you write it as an answer I will accept it. Otherwise, I will accept the other answer which does what your comment says.