Firstly, you need to remove the paragraph tags that were added by the wp_autop
filter. There’s another answer that covers this pretty well: Is there an uw-wp_autop function?
I’m going to change the function a little for our purposes (based on the markup example you gave):
function reverse_wpautop( $s ) {
// Strip newlines
$s = str_replace( "\n", "", $s );
// Strip all <p> tags
$s = str_replace( "<p>", "", $s );
// Replace </p> with a known delimiter
$s = str_replace( "</p>", "::|::", $s );
return $s;
}
If all is working correctly, this should convert your markup from:
<p>2012-12-12</p>
<p>2012-6-23</p>
<p>2012-7-3</p>
To:
2012-12-12::|::2012-6-23::|::2012-7-3::|::
If you do a split now, you’ll end up with an extra, empty element in your array. So remember to take a substring before you split:
function split_delimited_string( $s ) {
// Take a substring, removing the final 5 characters (::|::)
$s = substr( $s, 0, -5 );
return explode( "::|::", $s );
}