Say I have a string such as "&8My§4Name§2Is§7John"
I want to replace all the §'s with &'s however the regular replace functions don't seem to be working.
$string = "&8My§4Name§2Is§7John";
$string = preg_replace("/§/", "&", $string);
echo $string;
On the HTML page the echo comes out as:
&8My�4Name�2Is�7John
EDIT: It seems to work outside a function, when the string is passed into the function something seems to get scrambled.
Use str_replace
$string = "&8My§4Name§2Is§7John";
$string = str_replace("§", "&", $string);
echo $string;
this wored for me
<?php
$string = "&8My§4Name§2Is§7John";
$string = str_replace('§', '&', $string);
echo $string;
?>
if this don´t work try adding a meta tag
<meta charset="utf-8">
in your html