dt192 Posted November 10, 2008 Share Posted November 10, 2008 ok i have used preg_match_all before just fine but for some reason it just refuses to work for me tonight, i am just using it to grab a couple of values from some xml see example: <entry> <published>2008-11-08T15:12:41Z</published> <content type="html">bla bla bla</content> </entry> and what i want to be output is: <div>2008-11-08T15:12:41Z</div> <div>bla bla bla</div> <div>2008-11-08T17:14:44Z</div> <div>bla2 bla2 bla2</div> <div>2008-11-08T19:12:30Z</div> <div>bla bla bla</div> now i know both values can be grabbed at the same time via preg_match_all and are stored to an array but i just cant do it today lol so please help thanx Quote Link to comment Share on other sites More sharing options...
Jeremysr Posted November 10, 2008 Share Posted November 10, 2008 PHP has an XMLReader that can be used to easily read XML. I think that would be a much better choice for this. Quote Link to comment Share on other sites More sharing options...
ddrudik Posted November 10, 2008 Share Posted November 10, 2008 <?php $in='<entry> <published>2008-11-08T15:12:41Z</published> <content type="html">bla bla bla</content> </entry>'; $out=preg_replace('#<entry> <published>([^<]*)</published> <content type="html">([^<]*)</content> </entry>#','<div>$1</div> <div>$2</div>',$in); echo $out; ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.