Reading files, regular expression replacement ??
I want to replace 2.xmlin the attachment with a regular expression to make it as follows: (actually, the label is changed)
That is, let
Programming
Rasmus Lerdorf
Kevin Tatroe
1-56592-610-2
A greate book!
Replace
Programming
Rasmus Lerdorf
Kevin Tatroe
1-56692-610-2
Actually, it is to replace the tag, and the value remains unchanged.
How can I write this program? How can I replace the regular expression before reading the file? In addition, how can xml labels be written as regular expressions? Thank you.
Let me answer
Attachment: you cannot download or view attachments in your user group.
D8888D reply content -------------------------------------------------------
$ Ftext = file_get_contents ($ filename );
Preg_replace ('replacement string regular expression', 'replacement content', $ ftext );
D8888D reply content -------------------------------------------------------
Do you want to write more str_replace ..
D8888D reply content -------------------------------------------------------
Is this correct:
$ Xml = "books. xml ";
$ F = fopen ('books. xml', 'R ');
While ($ data = fread ($ f, 4096) {$ xml. = $ data ;}
Fclose ($ f );
$ Xmla = preg_replace ('/ ', 'Lil', $ xml );
$ Xmla = preg_replace (' ','/Lil', $ xmla );
Echo "$ xmla ";
?>
D8888D reply content -------------------------------------------------------
Is this correct:
Lxcupid published on [url = http://bbs.111cn.cn/redirect.php? Goto = findpost & pid = 1068481 & ptid = 128175] link mark [img] http://bbs.111cn.cn/images/common/back.gif?/img=#/url]
$ Xml = implode ("", file ('books. xml '));
$ Xmla = preg_replace ('/ ', 'Lil', $ xml );
$ Xmla = preg_replace (' ','/Lil', $ xmla );
Echo "$ xmla ";
?>
Copy code
D8888D reply content -------------------------------------------------------
$ Xml = implode ("", file ('books. xml '));
$ Xml = str_replace (array (' ',' '), Array (' ',' '), $ Xml); // set Replace , Set Replace
Copy code
D8888D reply content -------------------------------------------------------
Thank you, but it seems that some textures are missing. However, the result is not a new xml format.
D8888D reply content -------------------------------------------------------
The following code is as follows:
$ Xml = implode ("", file ('books. xml '));
$ Data = str_replace (array (' ',' '), Array (' ',' '), $ Xml );
// Set Replace , Set Replace
Echo $ data;
?>
However, the running result is:
Rasmus Lerdorf Kevin Tatroe 1-56592-610-2
Why cannot I display the New xml file I want ??
Attachment: you cannot download or view attachments in your user group.
D8888D reply content -------------------------------------------------------
Htmlentities () output with this function
D8888D reply content -------------------------------------------------------
Please provide more details. Thank you.