php preg replace

Posted by David on Stack Overflow See other posts from Stack Overflow or by David
Published on 2010-12-23T20:34:11Z Indexed on 2010/12/23 20:54 UTC
Read the original article Hit count: 261

Filed under:
|

I'm trying to build a PHP preg replace string when processing poorly written xml, such that if I am given:

$x='<abc x="y"><def x="g">more test</def x="g"><blah>test data</blah></abc x="y">';

That it checks if there's a space within a closing tag and deletes everything from the space to the end of the tag such that.

becomes

<abc x="y"><def x="g">more test</def><blah>test data</blah></abc>

thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about preg-replace