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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.