Jump to content

[SOLVED] Please make PHP preg_match_all work for me *cries*?


dt192

Recommended Posts

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

<?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;
?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.