Read the file and replace it with regular expression? ?
I want to replace 2.xml in the attachment with regular expressions so that it becomes as follows: (Actually, it means changing the tag)
That is, let
Rasmus Lerdorf
Kevin Tatroe
Dress up as
In fact, the label is replaced and the value remains unchanged.
How to write this program? First, we need to read the file, and then how to perform regular replacement? In addition, how to write xml tags as regular expressions? Thank you
Let me answer
Attachment: Your user group cannot download or view attachments
D8888D reply content------------------------------------------------- ----------
$ftext = file_get_contents($filename);
preg_replace('String regular expression to be replaced', 'Replacement content',$ftext);
D8888D reply content------------------------------------------------- ----------
How about writing a few more str_replaces..
D8888D reply content------------------------------------------------- ----------
Is it correct for me to write this:
$xml = "books.xml";
$f = fopen( 'books.xml', 'r' );
while( $data = fread( $f, 4096 ) ) { $xml .= $data; }
fclose( $f );
$xmla=preg_replace( '/
$xmla=preg_replace( '
echo "$xmla";
?>
D8888D reply content------------------------------------------------- ----------
Is it correct for me to write this:
lxcupid published on 2009-6-15 13:04 [url=http://bbs.111cn.cn/redirect.php?goto=findpost&pid=1068481&ptid=128175]Link tag[img]http://bbs.111cn.cn /images/common/back.gif[/img][/url]
$xml = implode("",file('books.xml'));
$xmla=preg_replace( '/
$xmla=preg_replace( '
echo "$xmla";
?>
Copy code
D8888D reply content------------------------------------------------- ----------
$xml = implode("",file('books.xml'));
$xml=str_replace( array('
Copy code
D8888D reply content------------------------------------------------- ----------
Thank you, but it seems that part of the sticker is missing, haha. But the result is not a new xml format.
D8888D reply content------------------------------------------------- ----------
The following is the code according to the code above:
$xml = implode("",file('books.xml'));
$data=str_replace( array('
// Replace
echo $data;
?>
But the running result is:
Rasmus Lerdorf Kevin Tatroe 1-56592-610-2
Why can't I display the new xml file I want? ?
Attachment: Your user group cannot download or view attachments
D8888D reply content------------------------------------------------- ----------
htmlentities() output plus this function
D8888D reply content------------------------------------------------- ----------
Please be more specific upstairs, thank you