Get all text between tags with preg_match_all() or better function?

Posted by kylex on Stack Overflow See other posts from Stack Overflow or by kylex
Published on 2010-06-17T16:46:33Z Indexed on 2010/06/17 16:53 UTC
Read the original article Hit count: 125

Filed under:
|
|
2010-June-11
<remove>2010-June-2</remove>
<remove>2010-June-3</remove>
2010-June-15
2010-June-16
2010-June-17
2010-June-3
2010-June-2
2010-June-1

I'm trying to find all instances that are between the <remove> tags

This is what I have:

$pattern = "/<remove>(.*?)<\/remove>/";
preg_match_all($pattern, $_POST['exclude'], $matches);

foreach($matches as $deselect){
    foreach ($deselect as $display){
        echo $display."<br />";
    }
}

This is what it returns:

2010-June-2
2010-June-3
2010-June-2
2010-June-3

Why is it doubling up, and how do I prevent that?

© Stack Overflow or respective owner

Related posts about php

Related posts about regex