<?php
$xmlfile = <<<EOD
<xml>
<log id="1088575085">
<data id="1088575085">Data1</data>
<title id="1088575085">Title1</title>
<author id="1088575085">Author1</author>
</log>
<log id="1088575185">
<data id="1088575185">Data2</data>
<title id="1088575185">Title2</title>
<author id="1088575185">Author2</author>
</log>
<log id="1088575285">
<data id="1088575285">Data3</data>
<title id="1088575285">Title3</title>
<author id="1088575285">Author3</author>
</log>
<log id="1088575385">
<data id="1088575385">Data4</data>
<title id="1088575385">Title4</title>
<author id="1088575385">Author4</author>
</log>
</xml>
EOD;
function XML_Delete($id,$mode)
{
global $xmlfile;
if($mode=="entry")
{
$find = "<log id=\"$id\">.+</log>\r\n";
$string = ereg_replace($find,"",textfile($xmlfile)); // textfile() just take a file and returns the text of it
$handle = fopen($xmlfile, "w+");
fwrite($handle, $string);
fclose($handle);
}
}
XML_Delete("1088575185","entry");
?>
What I'm trying to do is replace one set of <log> tags with everything thats nested in between. The problem that I keep running into is that ereg goes all the way to the last occurence of </log>. What I need is for the script to go only to the next occurence of </log> and stop there. Is there anyway to get ereg to stop at the occurence of some text (i.e. the next <log> tag)? Thanks.