Hello, I'm working on a php script for a game I'm doing.
What it is supossed to do: delete some strngs from an XML file.
The XML tags' info I want to remove:
<info start="blabla+bleble" end="June 5, 2006, 11:27&#;" reason="Blabla"/>
I'm using the function preg_replace to remove the information inside the tags.
It's supossed to work like this:
$sp = "";
@$filen = file_get_contents("$file");
$old[0] = "/start=\"$oldstart\"/";
$new[0] = start="'.$sp.'"';
$old[1] = "/end=\"$olddate\"/";
$new[1] = end="'.$sp.'"';
$old[2] = "/reason=\"$oldreason\"/";
$new[2] = reason="'.$sp.'"';
$files = preg_replace($old, $new, $filen);
$file_name = "$file";
$fp = fopen($file_name,"w");
fwrite($fp,$files);
fclose($fp);
With that, it's supossed to replace the old information with nothing, I tried just
$new[0] = start=""';
but it kept giving me errors, figured out that the easiest way to do it was with that $sp thing.
The problem is that only the contents of the "reason" tag are removed.
I can't delete the other two, on the "start" one I need to manually delete the "+" so the script works, and on the "end" one, I need to delete "&" to make the script work.
Do you know why can't the script delete this characters automatically? and is there anyway to delete them?