Reading files, regular expression replacement ?? _ PHP Tutorial

Source: Internet
Author: User
Read the file and replace the regular expression ??. Reading files, regular expression replacement ?? I want to replace the 2.xmlin the attachment with a regular expression, so that it becomes the following :( in fact, it is to change the label) that is to let the programmingRasmusLerdorfKevinTatroe1-5 read the file, 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 ";



?>




D8888D reply content -------------------------------------------------------
$ Xml = implode ("", file ('books. XML '));

$ Xml = str_replace (array (' ',' '), Array (' ',' '), $ Xml); // Set Replace , Set Replace




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.


Why ?? I want to replace 2.xmlin the attachment with a regular expression, and change it to the following: (actually, change the label) that is, let programming Rasmus Lerdorf Kevin Tatroe 1-5...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.