Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   search and replace over a file (http://www.go4expert.com/forums/search-replace-file-t11509/)

dirdamalah 20Jun2008 22:35

search and replace over a file
 
Hello

I have this regular expression:
</book>(?:\n)<collection>(.*)</collectioninfo>

And I have this peace of text on a FILE

<book bookid="3" title="the title 3" remaining = "50" price="100">
<reader readerid="1"><![CDATA[John]]></reader>
<reader readerid="2"><![CDATA[Michael]]></reader>
<reader readerid="3"><![CDATA[Peter]]></reader>
<reader readerid="4"><![CDATA[Maria]]></reader>
</book>
<collectioninfo id="123">
<title>colletion 1</title>
<date>Jun 19 11:00</date>
<type>2</type>
<limit>100</limit>
</collectioninfo>


<book bookid="4" title="the title 4" remaining = "50" price="100">
<reader readerid="1"><![CDATA[John]]></reader>
<reader readerid="2"><![CDATA[Michael]]></reader>
<reader readerid="3"><![CDATA[Peter]]></reader>
<reader readerid="4"><![CDATA[Maria]]></reader>
</book>


And i need replace the text in BOLD for:

</book>


So... using PHP how can I do that ... but saving the result in the same file..

I mean.. replace the current text on a file.. for the new one..

Thx.


All times are GMT +5.5. The time now is 00:11.